| author | paulson <lp15@cam.ac.uk> |
| Fri, 18 Feb 2022 21:40:01 +0000 | |
| changeset 75101 | f0e2023f361a |
| parent 75038 | e5750bcb8c41 |
| child 75343 | 62f0fda48a39 |
| permissions | -rw-r--r-- |
| 47847 | 1 |
(* Title: HOL/Mirabelle/Tools/mirabelle_sledgehammer.ML |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
2 |
Author: Jasmin Blanchette, TU Munich |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
3 |
Author: Sascha Boehme, TU Munich |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
4 |
Author: Tobias Nipkow, TU Munich |
| 73697 | 5 |
Author: Makarius |
|
74897
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
6 |
Author: Martin Desharnais, UniBw Munich, MPI-INF Saarbruecken |
|
73691
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
73292
diff
changeset
|
7 |
|
|
2f9877db82a1
reimplemented Mirabelle as Isabelle/ML presentation hook + Isabelle/Scala tool, but sledgehammer is still inactive;
wenzelm
parents:
73292
diff
changeset
|
8 |
Mirabelle action: "sledgehammer". |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
9 |
*) |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
10 |
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
11 |
structure Mirabelle_Sledgehammer: MIRABELLE_ACTION = |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
12 |
struct |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
13 |
|
|
47480
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
14 |
(*To facilitate synching the description of Mirabelle Sledgehammer parameters |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
15 |
(in ../lib/Tools/mirabelle) with the parameters actually used by this |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
16 |
interface, the former extracts PARAMETER and DESCRIPTION from code below which |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
17 |
has this pattern (provided it appears in a single line): |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
18 |
val .*K = "PARAMETER" (*DESCRIPTION*) |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
19 |
*) |
|
72342
4195e75a92ef
[mirabelle] add initial documentation in Sledgehammer's doc
desharna
parents:
72173
diff
changeset
|
20 |
(* NOTE: Do not forget to update the Sledgehammer documentation to reflect changes here. *) |
| 72173 | 21 |
|
22 |
val check_trivialK = "check_trivial" (*=BOOL: check if goals are "trivial"*) |
|
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
23 |
val keep_probsK = "keep_probs" (*=BOOL: keep temporary problem files created by sledgehammer*) |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
24 |
val keep_proofsK = "keep_proofs" (*=BOOL: keep temporary proof files created by ATPs*) |
| 73849 | 25 |
val proof_methodK = "proof_method" (*=STRING: how to reconstruct proofs (e.g. using metis)*) |
| 72173 | 26 |
val term_orderK = "term_order" (*=STRING: term order (in E)*) |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
27 |
|
|
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
28 |
(*defaults used in this Mirabelle action*) |
|
73292
f84a93f1de2f
tuned Mirabelle to parse option check_trivial only once
desharna
parents:
73289
diff
changeset
|
29 |
val check_trivial_default = false |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
30 |
val keep_probs_default = false |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
31 |
val keep_proofs_default = false |
|
46826
4c80c4034f1d
added max_new_mono_instances, max_mono_iters, to Mirabelle-Sledgehammer; changed sh_minimize to avoid setting Mirabelle-level defaults;
sultana
parents:
46825
diff
changeset
|
32 |
|
| 32549 | 33 |
datatype sh_data = ShData of {
|
34 |
calls: int, |
|
35 |
success: int, |
|
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
36 |
nontriv_calls: int, |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
37 |
nontriv_success: int, |
| 32585 | 38 |
lemmas: int, |
| 32818 | 39 |
max_lems: int, |
| 32549 | 40 |
time_isa: int, |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
41 |
time_prover: int} |
| 32549 | 42 |
|
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
43 |
datatype re_data = ReData of {
|
| 32549 | 44 |
calls: int, |
45 |
success: int, |
|
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
46 |
nontriv_calls: int, |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
47 |
nontriv_success: int, |
| 32676 | 48 |
proofs: int, |
| 32549 | 49 |
time: int, |
| 32550 | 50 |
timeout: int, |
| 32990 | 51 |
lemmas: int * int * int, |
|
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
52 |
posns: (Position.T * bool) list |
| 32550 | 53 |
} |
| 32549 | 54 |
|
| 32818 | 55 |
fun make_sh_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
56 |
(calls,success,nontriv_calls,nontriv_success,lemmas,max_lems,time_isa, |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
57 |
time_prover) = |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
58 |
ShData{calls=calls, success=success, nontriv_calls=nontriv_calls,
|
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
59 |
nontriv_success=nontriv_success, lemmas=lemmas, max_lems=max_lems, |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
60 |
time_isa=time_isa, time_prover=time_prover} |
| 32521 | 61 |
|
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
62 |
fun make_re_data (calls,success,nontriv_calls,nontriv_success,proofs,time, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
63 |
timeout,lemmas,posns) = |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
64 |
ReData{calls=calls, success=success, nontriv_calls=nontriv_calls,
|
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
65 |
nontriv_success=nontriv_success, proofs=proofs, time=time, |
| 32990 | 66 |
timeout=timeout, lemmas=lemmas, posns=posns} |
| 32549 | 67 |
|
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
68 |
val empty_sh_data = make_sh_data (0, 0, 0, 0, 0, 0, 0, 0) |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
69 |
val empty_re_data = make_re_data (0, 0, 0, 0, 0, 0, 0, (0,0,0), []) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
70 |
|
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
71 |
fun tuple_of_sh_data (ShData {calls, success, nontriv_calls, nontriv_success, lemmas, max_lems,
|
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
72 |
time_isa, time_prover}) = |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
73 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
74 |
|
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
75 |
fun tuple_of_re_data (ReData {calls, success, nontriv_calls, nontriv_success,
|
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
76 |
proofs, time, timeout, lemmas, posns}) = (calls, success, nontriv_calls, |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
77 |
nontriv_success, proofs, time, timeout, lemmas, posns) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
78 |
|
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
79 |
datatype data = Data of {
|
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
80 |
sh: sh_data, |
| 57753 | 81 |
re_u: re_data (* proof method with unminimized set of lemmas *) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
82 |
} |
| 32521 | 83 |
|
| 73697 | 84 |
type change_data = (data -> data) -> unit |
85 |
||
| 57753 | 86 |
fun make_data (sh, re_u) = Data {sh=sh, re_u=re_u}
|
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
87 |
|
| 57753 | 88 |
val empty_data = make_data (empty_sh_data, empty_re_data) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
89 |
|
| 57753 | 90 |
fun map_sh_data f (Data {sh, re_u}) =
|
| 57752 | 91 |
let val sh' = make_sh_data (f (tuple_of_sh_data sh)) |
| 57753 | 92 |
in make_data (sh', re_u) end |
| 32521 | 93 |
|
| 57753 | 94 |
fun map_re_data f (Data {sh, re_u}) =
|
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
95 |
let |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
96 |
val f' = make_re_data o f o tuple_of_re_data |
| 57753 | 97 |
val re_u' = f' re_u |
98 |
in make_data (sh, re_u') end |
|
| 32990 | 99 |
|
100 |
fun inc_max (n:int) (s,sos,m) = (s+n, sos + n*n, Int.max(m,n)); |
|
| 32521 | 101 |
|
| 32818 | 102 |
val inc_sh_calls = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
103 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
104 |
(calls + 1, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover)) |
| 32549 | 105 |
|
| 32818 | 106 |
val inc_sh_success = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
107 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
108 |
(calls, success + 1, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover)) |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
109 |
|
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
110 |
val inc_sh_nontriv_calls = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
111 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
112 |
(calls, success, nontriv_calls + 1, nontriv_success, lemmas, max_lems, time_isa, time_prover)) |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
113 |
|
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
114 |
val inc_sh_nontriv_success = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
115 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
116 |
(calls, success, nontriv_calls, nontriv_success + 1, lemmas,max_lems, time_isa, time_prover)) |
| 32585 | 117 |
|
| 32818 | 118 |
fun inc_sh_lemmas n = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
119 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
120 |
(calls, success, nontriv_calls, nontriv_success, lemmas+n, max_lems, time_isa, time_prover)) |
| 32521 | 121 |
|
| 32818 | 122 |
fun inc_sh_max_lems n = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
123 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
124 |
(calls, success,nontriv_calls, nontriv_success, lemmas, Int.max (max_lems, n), time_isa, |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
125 |
time_prover)) |
| 32549 | 126 |
|
| 32818 | 127 |
fun inc_sh_time_isa t = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
128 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
129 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa + t, time_prover)) |
| 32818 | 130 |
|
| 40062 | 131 |
fun inc_sh_time_prover t = map_sh_data |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
132 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover) => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
133 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover + t)) |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
134 |
|
| 55285 | 135 |
val inc_proof_method_calls = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
136 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
137 |
=> (calls + 1, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas,posns)) |
| 32533 | 138 |
|
| 55285 | 139 |
val inc_proof_method_success = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
140 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
141 |
=> (calls, success + 1, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas,posns)) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
142 |
|
| 55285 | 143 |
val inc_proof_method_nontriv_calls = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
144 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
145 |
=> (calls, success, nontriv_calls + 1, nontriv_success, proofs, time, timeout, lemmas,posns)) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
146 |
|
| 55285 | 147 |
val inc_proof_method_nontriv_success = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
148 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
149 |
=> (calls, success, nontriv_calls, nontriv_success + 1, proofs, time, timeout, lemmas,posns)) |
| 32676 | 150 |
|
| 55285 | 151 |
val inc_proof_method_proofs = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
152 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
153 |
=> (calls, success, nontriv_calls, nontriv_success, proofs + 1, time, timeout, lemmas,posns)) |
|
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
154 |
|
| 57753 | 155 |
fun inc_proof_method_time t = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
156 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
157 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time + t, timeout, lemmas,posns)) |
| 32536 | 158 |
|
| 55285 | 159 |
val inc_proof_method_timeout = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
160 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
161 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout + 1, lemmas,posns)) |
| 32549 | 162 |
|
| 57753 | 163 |
fun inc_proof_method_lemmas n = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
164 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
| 57753 | 165 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, inc_max n lemmas, posns)) |
|
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
166 |
|
| 57753 | 167 |
fun inc_proof_method_posns pos = map_re_data |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
168 |
(fn (calls,success,nontriv_calls, nontriv_success, proofs,time,timeout,lemmas,posns) |
| 57753 | 169 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas, pos::posns)) |
| 32521 | 170 |
|
| 44090 | 171 |
val str0 = string_of_int o the_default 0 |
172 |
||
| 32521 | 173 |
local |
174 |
||
175 |
val str = string_of_int |
|
176 |
val str3 = Real.fmt (StringCvt.FIX (SOME 3)) |
|
177 |
fun percentage a b = string_of_int (a * 100 div b) |
|
| 73697 | 178 |
fun ms t = Real.fromInt t / 1000.0 |
| 32521 | 179 |
fun avg_time t n = |
180 |
if n > 0 then (Real.fromInt t / 1000.0) / Real.fromInt n else 0.0 |
|
181 |
||
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
182 |
fun log_sh_data (ShData {calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa,
|
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
183 |
time_prover}) = |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
184 |
"\nTotal number of sledgehammer calls: " ^ str calls ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
185 |
"\nNumber of successful sledgehammer calls: " ^ str success ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
186 |
"\nNumber of sledgehammer lemmas: " ^ str lemmas ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
187 |
"\nMax number of sledgehammer lemmas: " ^ str max_lems ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
188 |
"\nSuccess rate: " ^ percentage success calls ^ "%" ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
189 |
"\nTotal number of nontrivial sledgehammer calls: " ^ str nontriv_calls ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
190 |
"\nNumber of successful nontrivial sledgehammer calls: " ^ str nontriv_success ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
191 |
"\nTotal time for sledgehammer calls (Isabelle): " ^ str3 (ms time_isa) ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
192 |
"\nTotal time for successful sledgehammer calls (ATP): " ^ str3 (ms time_prover) ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
193 |
"\nAverage time for sledgehammer calls (Isabelle): " ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
194 |
str3 (avg_time time_isa calls) ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
195 |
"\nAverage time for successful sledgehammer calls (ATP): " ^ |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
196 |
str3 (avg_time time_prover success) |
| 32521 | 197 |
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
198 |
fun log_re_data sh_calls (ReData {calls, success, nontriv_calls, nontriv_success, proofs, time,
|
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
199 |
timeout, lemmas = (lemmas, lems_sos, lems_max), posns}) = |
| 73697 | 200 |
let |
201 |
val proved = |
|
202 |
posns |> map (fn (pos, triv) => |
|
203 |
str0 (Position.line_of pos) ^ ":" ^ str0 (Position.offset_of pos) ^ |
|
204 |
(if triv then "[T]" else "")) |
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
205 |
in |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
206 |
"\nTotal number of proof method calls: " ^ str calls ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
207 |
"\nNumber of successful proof method calls: " ^ str success ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
208 |
" (proof: " ^ str proofs ^ ")" ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
209 |
"\nNumber of proof method timeouts: " ^ str timeout ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
210 |
"\nSuccess rate: " ^ percentage success sh_calls ^ "%" ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
211 |
"\nTotal number of nontrivial proof method calls: " ^ str nontriv_calls ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
212 |
"\nNumber of successful nontrivial proof method calls: " ^ str nontriv_success ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
213 |
" (proof: " ^ str proofs ^ ")" ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
214 |
"\nNumber of successful proof method lemmas: " ^ str lemmas ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
215 |
"\nSOS of successful proof method lemmas: " ^ str lems_sos ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
216 |
"\nMax number of successful proof method lemmas: " ^ str lems_max ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
217 |
"\nTotal time for successful proof method calls: " ^ str3 (ms time) ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
218 |
"\nAverage time for successful proof method calls: " ^ str3 (avg_time time success) ^ |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
219 |
"\nProved: " ^ space_implode " " proved |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
220 |
end |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
221 |
|
| 32521 | 222 |
in |
223 |
||
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
224 |
fun log_data (Data {sh, re_u}) =
|
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
225 |
let |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
226 |
val ShData {calls=sh_calls, ...} = sh
|
| 73697 | 227 |
val ReData {calls=re_calls, ...} = re_u
|
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
228 |
in |
| 73697 | 229 |
if sh_calls > 0 then |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
230 |
let val text1 = log_sh_data sh in |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
231 |
if re_calls > 0 then text1 ^ "\n" ^ log_re_data sh_calls re_u else text1 |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
232 |
end |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
233 |
else |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
234 |
"" |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
235 |
end |
| 32521 | 236 |
|
237 |
end |
|
238 |
||
| 46340 | 239 |
type stature = ATP_Problem_Generate.stature |
|
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
240 |
|
| 58473 | 241 |
fun is_good_line s = |
|
53081
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
242 |
(String.isSubstring " ms)" s orelse String.isSubstring " s)" s) |
|
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
243 |
andalso not (String.isSubstring "(> " s) |
|
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
244 |
andalso not (String.isSubstring ", > " s) |
|
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
245 |
andalso not (String.isSubstring "may fail" s) |
|
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
246 |
|
| 51206 | 247 |
(* Fragile hack *) |
| 55285 | 248 |
fun proof_method_from_msg args msg = |
249 |
(case AList.lookup (op =) args proof_methodK of |
|
| 58473 | 250 |
SOME name => |
251 |
if name = "smart" then |
|
252 |
if exists is_good_line (split_lines msg) then |
|
253 |
"none" |
|
254 |
else |
|
255 |
"fail" |
|
256 |
else |
|
257 |
name |
|
|
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
258 |
| NONE => |
| 58473 | 259 |
if exists is_good_line (split_lines msg) then |
| 51203 | 260 |
"none" (* trust the preplayed proof *) |
261 |
else if String.isSubstring "metis (" msg then
|
|
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
262 |
msg |> Substring.full |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
263 |
|> Substring.position "metis ("
|
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
264 |
|> snd |> Substring.position ")" |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
265 |
|> fst |> Substring.string |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
266 |
|> suffix ")" |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
267 |
else if String.isSubstring "metis" msg then |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
268 |
"metis" |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
269 |
else |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
270 |
"smt") |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
271 |
|
| 32521 | 272 |
local |
273 |
||
| 75028 | 274 |
fun run_sh params term_order keep pos state = |
| 32521 | 275 |
let |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
276 |
fun set_file_name (SOME (dir, keep_probs, keep_proofs)) = |
| 74892 | 277 |
let |
278 |
val filename = "prob_" ^ |
|
| 74472 | 279 |
StringCvt.padLeft #"0" 5 (str0 (Position.line_of pos)) ^ "_" ^ |
| 74892 | 280 |
StringCvt.padLeft #"0" 6 (str0 (Position.offset_of pos)) |
281 |
in |
|
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
282 |
Config.put Sledgehammer_Prover_ATP.atp_problem_prefix (filename ^ "__") |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
283 |
#> (keep_probs ? Config.put Sledgehammer_Prover_ATP.atp_problem_dest_dir dir) |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
284 |
#> (keep_proofs ? Config.put Sledgehammer_Prover_ATP.atp_proof_dest_dir dir) |
| 74892 | 285 |
#> Config.put SMT_Config.debug_files (dir ^ "/" ^ filename ^ "__" ^ serial_string ()) |
286 |
end |
|
| 44090 | 287 |
| set_file_name NONE = I |
|
74950
b350a1f2115d
added nearly_all_facts_of_context and uniformized its usage in Sledgehammer and Mirabelle
desharna
parents:
74948
diff
changeset
|
288 |
val state' = |
|
b350a1f2115d
added nearly_all_facts_of_context and uniformized its usage in Sledgehammer and Mirabelle
desharna
parents:
74948
diff
changeset
|
289 |
state |
| 47030 | 290 |
|> Proof.map_context |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
291 |
(set_file_name keep |
| 72400 | 292 |
#> (Option.map (Config.put Sledgehammer_ATP_Systems.term_order) |
|
75024
114eb0af123d
simplified 'best_slice' data structure and made minor changes to slices
blanchet
parents:
75004
diff
changeset
|
293 |
term_order |> the_default I)) |
|
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
294 |
|
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
295 |
val ((_, (sledgehammer_outcome, msg)), cpu_time) = Mirabelle.cpu_time (fn () => |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
296 |
Sledgehammer.run_sledgehammer params Sledgehammer_Prover.Normal NONE 1 |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
297 |
Sledgehammer_Fact.no_fact_override state') () |
| 32521 | 298 |
in |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
299 |
(sledgehammer_outcome, msg, cpu_time) |
| 32521 | 300 |
end |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
301 |
handle |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
302 |
ERROR msg => (Sledgehammer.SH_Unknown, " error: " ^ msg, 0) |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
303 |
| _ => (Sledgehammer.SH_Unknown, " error: unexpected error", 0) |
| 32521 | 304 |
|
|
32498
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
305 |
in |
|
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
306 |
|
| 75028 | 307 |
fun run_sledgehammer (params as {provers, ...}) output_dir term_order
|
|
75024
114eb0af123d
simplified 'best_slice' data structure and made minor changes to slices
blanchet
parents:
75004
diff
changeset
|
308 |
keep_probs keep_proofs proof_method_from_msg thy_index trivial pos st = |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
309 |
let |
| 55205 | 310 |
val thy = Proof.theory_of st |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
311 |
val thy_name = Context.theory_name thy |
| 39340 | 312 |
val triv_str = if trivial then "[T] " else "" |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
313 |
val keep = |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
314 |
if keep_probs orelse keep_proofs then |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
315 |
let val subdir = StringCvt.padLeft #"0" 4 (string_of_int thy_index) ^ "_" ^ thy_name in |
|
74078
a2cbe81e1e32
changed Mirabelle_Sledgehammer keep option from path to boolean
desharna
parents:
73849
diff
changeset
|
316 |
Path.append output_dir (Path.basic subdir) |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
317 |
|> Isabelle_System.make_directory |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
318 |
|> Path.implode |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
319 |
|> (fn dir => SOME (dir, keep_probs, keep_proofs)) |
|
74078
a2cbe81e1e32
changed Mirabelle_Sledgehammer keep option from path to boolean
desharna
parents:
73849
diff
changeset
|
320 |
end |
|
a2cbe81e1e32
changed Mirabelle_Sledgehammer keep option from path to boolean
desharna
parents:
73849
diff
changeset
|
321 |
else |
|
a2cbe81e1e32
changed Mirabelle_Sledgehammer keep option from path to boolean
desharna
parents:
73849
diff
changeset
|
322 |
NONE |
|
74897
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
323 |
val prover_name = hd provers |
| 75028 | 324 |
val (sledgehamer_outcome, msg, cpu_time) = run_sh params term_order keep pos st |
| 75001 | 325 |
val (time_prover, change_data, proof_method_and_used_thms) = |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
326 |
(case sledgehamer_outcome of |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
327 |
Sledgehammer.SH_Some {used_facts, run_time, ...} =>
|
| 38700 | 328 |
let |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
329 |
val num_used_facts = length used_facts |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
330 |
val time_prover = Time.toMilliseconds run_time |
| 46340 | 331 |
fun get_thms (name, stature) = |
|
50267
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
smolkas
parents:
49916
diff
changeset
|
332 |
try (Sledgehammer_Util.thms_of_name (Proof.context_of st)) |
|
49916
412346127bfa
fixed theorem lookup code in Isar proof reconstruction
blanchet
parents:
49914
diff
changeset
|
333 |
name |
|
47154
2c357e2b8436
more robustness in case a theorem cannot be retrieved (which typically happens with backtick facts)
blanchet
parents:
47060
diff
changeset
|
334 |
|> Option.map (pair (name, stature)) |
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
335 |
val change_data = |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
336 |
inc_sh_success |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
337 |
#> not trivial ? inc_sh_nontriv_success |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
338 |
#> inc_sh_lemmas num_used_facts |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
339 |
#> inc_sh_max_lems num_used_facts |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
340 |
#> inc_sh_time_prover time_prover |
| 32525 | 341 |
in |
| 75001 | 342 |
(SOME time_prover, change_data, |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
343 |
SOME (proof_method_from_msg msg, map_filter get_thms used_facts)) |
| 32525 | 344 |
end |
| 75001 | 345 |
| _ => (NONE, I, NONE)) |
346 |
val outcome_msg = |
|
347 |
"(SH " ^ string_of_int cpu_time ^ "ms" ^ |
|
348 |
(case time_prover of NONE => "" | SOME ms => ", ATP " ^ string_of_int ms ^ "ms") ^ |
|
349 |
") [" ^ prover_name ^ "]: " |
|
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
350 |
in |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
351 |
(sledgehamer_outcome, triv_str ^ outcome_msg ^ msg, change_data #> inc_sh_time_isa cpu_time, |
|
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
352 |
proof_method_and_used_thms) |
| 32525 | 353 |
end |
354 |
||
355 |
end |
|
356 |
||
| 44542 | 357 |
fun override_params prover type_enc timeout = |
358 |
[("provers", prover),
|
|
| 48293 | 359 |
("max_facts", "0"),
|
| 44542 | 360 |
("type_enc", type_enc),
|
| 46386 | 361 |
("strict", "true"),
|
| 45706 | 362 |
("slice", "false"),
|
| 44461 | 363 |
("timeout", timeout |> Time.toSeconds |> string_of_int)]
|
| 44430 | 364 |
|
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
365 |
fun run_proof_method trivial full name meth named_thms timeout pos st = |
| 32525 | 366 |
let |
| 55285 | 367 |
fun do_method named_thms ctxt = |
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
368 |
let |
| 59083 | 369 |
val ref_of_str = (* FIXME proper wrapper for parser combinators *) |
370 |
suffix ";" #> Token.explode (Thy_Header.get_keywords' ctxt) Position.none |
|
| 62969 | 371 |
#> Parse.thm #> fst |
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
372 |
val thms = named_thms |> maps snd |
|
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
373 |
val facts = named_thms |> map (ref_of_str o fst o fst) |
| 48292 | 374 |
val fact_override = {add = facts, del = [], only = true}
|
|
44566
bf8331161ad9
split timeout among ATPs in and add Metis to the mix as backup
blanchet
parents:
44542
diff
changeset
|
375 |
fun my_timeout time_slice = |
| 62826 | 376 |
timeout |> Time.toReal |> curry (op *) time_slice |> Time.fromReal |
|
44566
bf8331161ad9
split timeout among ATPs in and add Metis to the mix as backup
blanchet
parents:
44542
diff
changeset
|
377 |
fun sledge_tac time_slice prover type_enc = |
| 44542 | 378 |
Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt |
| 57814 | 379 |
(override_params prover type_enc (my_timeout time_slice)) fact_override [] |
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
380 |
in |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
381 |
if meth = "sledgehammer_tac" then |
| 75038 | 382 |
sledge_tac 0.25 ATP_Proof.vampireN "mono_native" |
383 |
ORELSE' sledge_tac 0.25 ATP_Proof.eN "poly_guards??" |
|
384 |
ORELSE' sledge_tac 0.25 ATP_Proof.spassN "mono_native" |
|
| 58061 | 385 |
ORELSE' SMT_Solver.smt_tac ctxt thms |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
386 |
else if meth = "smt" then |
| 58061 | 387 |
SMT_Solver.smt_tac ctxt thms |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
388 |
else if full then |
| 46320 | 389 |
Metis_Tactic.metis_tac [ATP_Proof_Reconstruct.full_typesN] |
| 54500 | 390 |
ATP_Proof_Reconstruct.default_metis_lam_trans ctxt thms |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
391 |
else if String.isPrefix "metis (" meth then
|
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
392 |
let |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
393 |
val (type_encs, lam_trans) = |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
394 |
meth |
| 59083 | 395 |
|> Token.explode (Thy_Header.get_keywords' ctxt) Position.start |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
396 |
|> filter Token.is_proper |> tl |
|
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
397 |
|> Metis_Tactic.parse_metis_options |> fst |
| 46320 | 398 |
|>> the_default [ATP_Proof_Reconstruct.partial_typesN] |
| 54500 | 399 |
||> the_default ATP_Proof_Reconstruct.default_metis_lam_trans |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
400 |
in Metis_Tactic.metis_tac type_encs lam_trans ctxt thms end |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
401 |
else if meth = "metis" then |
| 55211 | 402 |
Metis_Tactic.metis_tac [] ATP_Proof_Reconstruct.default_metis_lam_trans ctxt thms |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
403 |
else if meth = "none" then |
| 58473 | 404 |
K all_tac |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
405 |
else if meth = "fail" then |
| 58473 | 406 |
K no_tac |
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
407 |
else |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
408 |
(warning ("Unknown method " ^ quote meth); K no_tac)
|
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
409 |
end |
| 55285 | 410 |
fun apply_method named_thms = |
411 |
Mirabelle.can_apply timeout (do_method named_thms) st |
|
| 32521 | 412 |
|
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
413 |
fun with_time (false, t) = ("failed (" ^ string_of_int t ^ ")", I)
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
414 |
| with_time (true, t) = |
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
415 |
("succeeded (" ^ string_of_int t ^ ")",
|
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
416 |
inc_proof_method_success |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
417 |
#> not trivial ? inc_proof_method_nontriv_success |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
418 |
#> inc_proof_method_lemmas (length named_thms) |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
419 |
#> inc_proof_method_time t |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
420 |
#> inc_proof_method_posns (pos, trivial) |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
421 |
#> name = "proof" ? inc_proof_method_proofs) |
| 55285 | 422 |
fun timed_method named_thms = |
| 73697 | 423 |
with_time (Mirabelle.cpu_time apply_method named_thms) |
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
424 |
handle Timeout.TIMEOUT _ => ("timeout", inc_proof_method_timeout)
|
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
425 |
| ERROR msg => ("error: " ^ msg, I)
|
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
426 |
in |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
427 |
timed_method named_thms |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
428 |
|> apsnd (fn change_data => change_data |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
429 |
#> inc_proof_method_calls |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
430 |
#> not trivial ? inc_proof_method_nontriv_calls) |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
431 |
end |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
432 |
|
| 75004 | 433 |
val try0 = Try0.try0 (SOME (Time.fromSeconds 5)) ([], [], [], []) |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
434 |
|
|
74078
a2cbe81e1e32
changed Mirabelle_Sledgehammer keep option from path to boolean
desharna
parents:
73849
diff
changeset
|
435 |
fun make_action ({arguments, timeout, output_dir, ...} : Mirabelle.action_context) =
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
436 |
let |
|
74897
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
437 |
(* Parse Mirabelle-specific parameters *) |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
438 |
val check_trivial = |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
439 |
Mirabelle.get_bool_argument arguments (check_trivialK, check_trivial_default) |
|
74981
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
440 |
val keep_probs = Mirabelle.get_bool_argument arguments (keep_probsK, keep_probs_default) |
|
10df7a627ab6
split option "sledgehammer_atp_dest_dir" into "sledgehammer_atp_prob_dest_dir" and "sledgehammer_atp_proof_dest_dir"
desharna
parents:
74967
diff
changeset
|
441 |
val keep_proofs = Mirabelle.get_bool_argument arguments (keep_proofsK, keep_proofs_default) |
|
74897
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
442 |
val term_order = AList.lookup (op =) arguments term_orderK |
|
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
443 |
val proof_method_from_msg = proof_method_from_msg arguments |
|
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
444 |
|
|
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74892
diff
changeset
|
445 |
val params = Sledgehammer_Commands.default_params \<^theory> arguments |
|
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
446 |
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
447 |
val data = Synchronized.var "Mirabelle_Sledgehammer.data" empty_data |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
448 |
|
|
74948
15ce207f69c8
added support for initialization messages to Mirabelle
desharna
parents:
74897
diff
changeset
|
449 |
val init_msg = "Params for sledgehammer: " ^ Sledgehammer_Prover.string_of_params params |
|
15ce207f69c8
added support for initialization messages to Mirabelle
desharna
parents:
74897
diff
changeset
|
450 |
|
|
75003
f21e7e6172a0
renamed run_action to run in Mirabelle.action record
desharna
parents:
75001
diff
changeset
|
451 |
fun run ({theory_index, name, pos, pre, ...} : Mirabelle.command) =
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
452 |
let val goal = Thm.major_prem_of (#goal (Proof.goal pre)) in |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
453 |
if can Logic.dest_conjunction goal orelse can Logic.dest_equals goal then |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
454 |
"" |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
455 |
else |
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
456 |
let |
| 75004 | 457 |
val trivial = check_trivial andalso try0 pre handle Timeout.TIMEOUT _ => false |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
458 |
val (outcome, log1, change_data1, proof_method_and_used_thms) = |
| 75028 | 459 |
run_sledgehammer params output_dir term_order keep_probs keep_proofs |
460 |
proof_method_from_msg theory_index trivial pos pre |
|
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
461 |
val (log2, change_data2) = |
|
74997
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
462 |
(case proof_method_and_used_thms of |
|
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
463 |
SOME (proof_method, used_thms) => |
|
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
464 |
run_proof_method trivial false name proof_method used_thms timeout pos pre |
|
d4a52993a81e
removed unsynchronized references in mirabelle_sledgehammer
desharna
parents:
74996
diff
changeset
|
465 |
|> apfst (prefix (proof_method ^ " (sledgehammer): ")) |
|
74996
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
466 |
| NONE => ("", I))
|
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
467 |
val () = Synchronized.change data |
|
1f4c39ffb116
tuned mirabelle_sledgehammer to have a single call to Synchronized.change per run
desharna
parents:
74981
diff
changeset
|
468 |
(change_data1 #> change_data2 #> inc_sh_calls #> not trivial ? inc_sh_nontriv_calls) |
|
74967
3f55c5feca58
prefixed all mirabelle_sledgehammer output lines with sledgehammer output
desharna
parents:
74953
diff
changeset
|
469 |
in |
|
3f55c5feca58
prefixed all mirabelle_sledgehammer output lines with sledgehammer output
desharna
parents:
74953
diff
changeset
|
470 |
log1 ^ "\n" ^ log2 |
|
3f55c5feca58
prefixed all mirabelle_sledgehammer output lines with sledgehammer output
desharna
parents:
74953
diff
changeset
|
471 |
|> Symbol.trim_blanks |
|
3f55c5feca58
prefixed all mirabelle_sledgehammer output lines with sledgehammer output
desharna
parents:
74953
diff
changeset
|
472 |
|> prefix_lines (Sledgehammer.short_string_of_sledgehammer_outcome outcome ^ " ") |
|
3f55c5feca58
prefixed all mirabelle_sledgehammer output lines with sledgehammer output
desharna
parents:
74953
diff
changeset
|
473 |
end |
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
474 |
end |
| 73697 | 475 |
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
476 |
fun finalize () = log_data (Synchronized.value data) |
|
75003
f21e7e6172a0
renamed run_action to run in Mirabelle.action record
desharna
parents:
75001
diff
changeset
|
477 |
in (init_msg, {run = run, finalize = finalize}) end
|
|
73847
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
478 |
|
|
58f6b41efe88
refactored Mirabelle to produce output in real time
desharna
parents:
73797
diff
changeset
|
479 |
val () = Mirabelle.register_action "sledgehammer" make_action |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
480 |
|
|
74951
0b6f795d3b78
proper filtering inf induction rules in Mirabelle
desharna
parents:
74950
diff
changeset
|
481 |
end |