author | blanchet |
Mon, 27 Jun 2011 13:52:47 +0200 | |
changeset 43569 | b342cd125533 |
parent 43351 | b19d95b4d736 |
child 43626 | a867ebb12209 |
permissions | -rw-r--r-- |
32564 | 1 |
(* Title: HOL/Mirabelle/Tools/mirabelle_sledgehammer.ML |
2 |
Author: Jasmin Blanchette and Sascha Boehme and Tobias Nipkow, TU Munich |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
3 |
*) |
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
4 |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
5 |
structure Mirabelle_Sledgehammer : MIRABELLE_ACTION = |
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
6 |
struct |
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
7 |
|
32521 | 8 |
val proverK = "prover" |
32541 | 9 |
val prover_timeoutK = "prover_timeout" |
32521 | 10 |
val keepK = "keep" |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
11 |
val type_sysK = "type_sys" |
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
12 |
val slicingK = "slicing" |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
13 |
val e_weight_methodK = "e_weight_method" |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
14 |
val spass_force_sosK = "spass_force_sos" |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
15 |
val vampire_force_sosK = "vampire_force_sos" |
41752 | 16 |
val max_relevantK = "max_relevant" |
32525 | 17 |
val minimizeK = "minimize" |
18 |
val minimize_timeoutK = "minimize_timeout" |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
19 |
val metis_ftK = "metis_ft" |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
20 |
val reconstructorK = "reconstructor" |
32521 | 21 |
|
22 |
fun sh_tag id = "#" ^ string_of_int id ^ " sledgehammer: " |
|
32525 | 23 |
fun minimize_tag id = "#" ^ string_of_int id ^ " minimize (sledgehammer): " |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
24 |
fun reconstructor_tag reconstructor id = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
25 |
"#" ^ string_of_int id ^ " " ^ (!reconstructor) ^ " (sledgehammer): " |
32521 | 26 |
|
32525 | 27 |
val separator = "-----" |
28 |
||
32521 | 29 |
|
32549 | 30 |
datatype sh_data = ShData of { |
31 |
calls: int, |
|
32 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
33 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
34 |
nontriv_success: int, |
32585 | 35 |
lemmas: int, |
32818 | 36 |
max_lems: int, |
32549 | 37 |
time_isa: int, |
40062 | 38 |
time_prover: int, |
39 |
time_prover_fail: int} |
|
32549 | 40 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
41 |
datatype re_data = ReData of { |
32549 | 42 |
calls: int, |
43 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
44 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
45 |
nontriv_success: int, |
32676 | 46 |
proofs: int, |
32549 | 47 |
time: int, |
32550 | 48 |
timeout: int, |
32990 | 49 |
lemmas: int * int * int, |
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
50 |
posns: (Position.T * bool) list |
32550 | 51 |
} |
32549 | 52 |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
53 |
datatype min_data = MinData of { |
32609 | 54 |
succs: int, |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
55 |
ab_ratios: int |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
56 |
} |
32521 | 57 |
|
32818 | 58 |
fun make_sh_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
59 |
(calls,success,nontriv_calls,nontriv_success,lemmas,max_lems,time_isa, |
40062 | 60 |
time_prover,time_prover_fail) = |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
61 |
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
|
62 |
nontriv_success=nontriv_success, lemmas=lemmas, max_lems=max_lems, |
40062 | 63 |
time_isa=time_isa, time_prover=time_prover, |
64 |
time_prover_fail=time_prover_fail} |
|
32521 | 65 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
66 |
fun make_min_data (succs, ab_ratios) = |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
67 |
MinData{succs=succs, ab_ratios=ab_ratios} |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
68 |
|
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 |
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
|
70 |
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
|
71 |
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
|
72 |
nontriv_success=nontriv_success, proofs=proofs, time=time, |
32990 | 73 |
timeout=timeout, lemmas=lemmas, posns=posns} |
32549 | 74 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
75 |
val empty_sh_data = make_sh_data (0, 0, 0, 0, 0, 0, 0, 0, 0) |
35871
c93bda4fdf15
remove the iteration counter from Sledgehammer's minimizer
blanchet
parents:
35867
diff
changeset
|
76 |
val empty_min_data = make_min_data (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
|
77 |
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
|
78 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
79 |
fun tuple_of_sh_data (ShData {calls, success, nontriv_calls, nontriv_success, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
80 |
lemmas, max_lems, time_isa, |
40062 | 81 |
time_prover, time_prover_fail}) = (calls, success, nontriv_calls, |
82 |
nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail) |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
83 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
84 |
fun tuple_of_min_data (MinData {succs, ab_ratios}) = (succs, ab_ratios) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
85 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
90 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
91 |
datatype reconstructor_mode = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
92 |
Unminimized | Minimized | UnminimizedFT | MinimizedFT |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
93 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
94 |
datatype data = Data of { |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
95 |
sh: sh_data, |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
96 |
min: min_data, |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
97 |
re_u: re_data, (* reconstructor with unminimized set of lemmas *) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
98 |
re_m: re_data, (* reconstructor with minimized set of lemmas *) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
99 |
re_uft: re_data, (* reconstructor with unminimized set of lemmas and fully-typed *) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
100 |
re_mft: re_data, (* reconstructor with minimized set of lemmas and fully-typed *) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
101 |
mini: bool (* with minimization *) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
102 |
} |
32521 | 103 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
104 |
fun make_data (sh, min, re_u, re_m, re_uft, re_mft, mini) = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
105 |
Data {sh=sh, min=min, re_u=re_u, re_m=re_m, re_uft=re_uft, re_mft=re_mft, |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
106 |
mini=mini} |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
107 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
108 |
val empty_data = make_data (empty_sh_data, empty_min_data, |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
109 |
empty_re_data, empty_re_data, empty_re_data, empty_re_data, false) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
110 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
111 |
fun map_sh_data f (Data {sh, min, re_u, re_m, re_uft, re_mft, mini}) = |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
112 |
let val sh' = make_sh_data (f (tuple_of_sh_data sh)) |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
113 |
in make_data (sh', min, re_u, re_m, re_uft, re_mft, mini) end |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
114 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
115 |
fun map_min_data f (Data {sh, min, re_u, re_m, re_uft, re_mft, mini}) = |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
116 |
let val min' = make_min_data (f (tuple_of_min_data min)) |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
117 |
in make_data (sh, min', re_u, re_m, re_uft, re_mft, mini) end |
32521 | 118 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
119 |
fun map_re_data f m (Data {sh, min, re_u, re_m, re_uft, re_mft, mini}) = |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
120 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
121 |
fun map_me g Unminimized (u, m, uft, mft) = (g u, m, uft, mft) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
122 |
| map_me g Minimized (u, m, uft, mft) = (u, g m, uft, mft) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
123 |
| map_me g UnminimizedFT (u, m, uft, mft) = (u, m, g uft, mft) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
124 |
| map_me g MinimizedFT (u, m, uft, mft) = (u, m, uft, g mft) |
32521 | 125 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
126 |
val f' = make_re_data o f o tuple_of_re_data |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
127 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
128 |
val (re_u', re_m', re_uft', re_mft') = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
129 |
map_me f' m (re_u, re_m, re_uft, re_mft) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
130 |
in make_data (sh, min, re_u', re_m', re_uft', re_mft', mini) end |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
131 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
132 |
fun set_mini mini (Data {sh, min, re_u, re_m, re_uft, re_mft, ...}) = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
133 |
make_data (sh, min, re_u, re_m, re_uft, re_mft, mini) |
32990 | 134 |
|
135 |
fun inc_max (n:int) (s,sos,m) = (s+n, sos + n*n, Int.max(m,n)); |
|
32521 | 136 |
|
32818 | 137 |
val inc_sh_calls = map_sh_data |
40062 | 138 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
139 |
=> (calls + 1, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail)) |
|
32549 | 140 |
|
32818 | 141 |
val inc_sh_success = map_sh_data |
40062 | 142 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
143 |
=> (calls, success + 1, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail)) |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
144 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
145 |
val inc_sh_nontriv_calls = map_sh_data |
40062 | 146 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
147 |
=> (calls, success, nontriv_calls + 1, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail)) |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
148 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
149 |
val inc_sh_nontriv_success = map_sh_data |
40062 | 150 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
151 |
=> (calls, success, nontriv_calls, nontriv_success + 1, lemmas,max_lems, time_isa, time_prover, time_prover_fail)) |
|
32585 | 152 |
|
32818 | 153 |
fun inc_sh_lemmas n = map_sh_data |
40062 | 154 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
155 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas+n,max_lems,time_isa,time_prover,time_prover_fail)) |
|
32521 | 156 |
|
32818 | 157 |
fun inc_sh_max_lems n = map_sh_data |
40062 | 158 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
159 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,Int.max(max_lems,n),time_isa,time_prover,time_prover_fail)) |
|
32549 | 160 |
|
32818 | 161 |
fun inc_sh_time_isa t = map_sh_data |
40062 | 162 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
163 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa + t,time_prover,time_prover_fail)) |
|
32818 | 164 |
|
40062 | 165 |
fun inc_sh_time_prover t = map_sh_data |
166 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
167 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover + t,time_prover_fail)) |
|
32521 | 168 |
|
40062 | 169 |
fun inc_sh_time_prover_fail t = map_sh_data |
170 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
171 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail + t)) |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
172 |
|
32818 | 173 |
val inc_min_succs = map_min_data |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
174 |
(fn (succs,ab_ratios) => (succs+1, ab_ratios)) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
175 |
|
32818 | 176 |
fun inc_min_ab_ratios r = map_min_data |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
177 |
(fn (succs, ab_ratios) => (succs, ab_ratios+r)) |
32549 | 178 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
179 |
val inc_reconstructor_calls = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
180 |
(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
|
181 |
=> (calls + 1, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas,posns)) |
32533 | 182 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
183 |
val inc_reconstructor_success = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
184 |
(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
|
185 |
=> (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
|
186 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
187 |
val inc_reconstructor_nontriv_calls = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
188 |
(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
|
189 |
=> (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
|
190 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
191 |
val inc_reconstructor_nontriv_success = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
192 |
(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
|
193 |
=> (calls, success, nontriv_calls, nontriv_success + 1, proofs, time, timeout, lemmas,posns)) |
32676 | 194 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
195 |
val inc_reconstructor_proofs = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
196 |
(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
|
197 |
=> (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
|
198 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
199 |
fun inc_reconstructor_time m t = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
200 |
(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
|
201 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time + t, timeout, lemmas,posns)) m |
32536 | 202 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
203 |
val inc_reconstructor_timeout = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
204 |
(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
|
205 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout + 1, lemmas,posns)) |
32549 | 206 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
207 |
fun inc_reconstructor_lemmas m n = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
208 |
(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
|
209 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, inc_max n lemmas, posns)) m |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
210 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
211 |
fun inc_reconstructor_posns m pos = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
212 |
(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
|
213 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas, pos::posns)) m |
32521 | 214 |
|
215 |
local |
|
216 |
||
217 |
val str = string_of_int |
|
218 |
val str3 = Real.fmt (StringCvt.FIX (SOME 3)) |
|
219 |
fun percentage a b = string_of_int (a * 100 div b) |
|
220 |
fun time t = Real.fromInt t / 1000.0 |
|
221 |
fun avg_time t n = |
|
222 |
if n > 0 then (Real.fromInt t / 1000.0) / Real.fromInt n else 0.0 |
|
223 |
||
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
224 |
fun log_sh_data log |
40062 | 225 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail) = |
32818 | 226 |
(log ("Total number of sledgehammer calls: " ^ str calls); |
227 |
log ("Number of successful sledgehammer calls: " ^ str success); |
|
228 |
log ("Number of sledgehammer lemmas: " ^ str lemmas); |
|
229 |
log ("Max number of sledgehammer lemmas: " ^ str max_lems); |
|
230 |
log ("Success rate: " ^ percentage success calls ^ "%"); |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
231 |
log ("Total number of nontrivial sledgehammer calls: " ^ str nontriv_calls); |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
232 |
log ("Number of successful nontrivial sledgehammer calls: " ^ str nontriv_success); |
32818 | 233 |
log ("Total time for sledgehammer calls (Isabelle): " ^ str3 (time time_isa)); |
40062 | 234 |
log ("Total time for successful sledgehammer calls (ATP): " ^ str3 (time time_prover)); |
235 |
log ("Total time for failed sledgehammer calls (ATP): " ^ str3 (time time_prover_fail)); |
|
32536 | 236 |
log ("Average time for sledgehammer calls (Isabelle): " ^ |
32818 | 237 |
str3 (avg_time time_isa calls)); |
32533 | 238 |
log ("Average time for successful sledgehammer calls (ATP): " ^ |
40062 | 239 |
str3 (avg_time time_prover success)); |
32536 | 240 |
log ("Average time for failed sledgehammer calls (ATP): " ^ |
40062 | 241 |
str3 (avg_time time_prover_fail (calls - success))) |
32533 | 242 |
) |
32521 | 243 |
|
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
244 |
|
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
245 |
fun str_of_pos (pos, triv) = |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
246 |
let val str0 = string_of_int o the_default 0 |
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
247 |
in |
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
248 |
str0 (Position.line_of pos) ^ ":" ^ str0 (Position.column_of pos) ^ |
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
249 |
(if triv then "[T]" else "") |
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
250 |
end |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
251 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
252 |
fun log_re_data log tag sh_calls (re_calls, re_success, re_nontriv_calls, |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
253 |
re_nontriv_success, re_proofs, re_time, re_timeout, |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
254 |
(lemmas, lems_sos, lems_max), re_posns) = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
255 |
(log ("Total number of " ^ tag ^ "reconstructor calls: " ^ str re_calls); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
256 |
log ("Number of successful " ^ tag ^ "reconstructor calls: " ^ str re_success ^ |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
257 |
" (proof: " ^ str re_proofs ^ ")"); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
258 |
log ("Number of " ^ tag ^ "reconstructor timeouts: " ^ str re_timeout); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
259 |
log ("Success rate: " ^ percentage re_success sh_calls ^ "%"); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
260 |
log ("Total number of nontrivial " ^ tag ^ "reconstructor calls: " ^ str re_nontriv_calls); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
261 |
log ("Number of successful nontrivial " ^ tag ^ "reconstructor calls: " ^ str re_nontriv_success ^ |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
262 |
" (proof: " ^ str re_proofs ^ ")"); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
263 |
log ("Number of successful " ^ tag ^ "reconstructor lemmas: " ^ str lemmas); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
264 |
log ("SOS of successful " ^ tag ^ "reconstructor lemmas: " ^ str lems_sos); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
265 |
log ("Max number of successful " ^ tag ^ "reconstructor lemmas: " ^ str lems_max); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
266 |
log ("Total time for successful " ^ tag ^ "reconstructor calls: " ^ str3 (time re_time)); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
267 |
log ("Average time for successful " ^ tag ^ "reconstructor calls: " ^ |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
268 |
str3 (avg_time re_time re_success)); |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
269 |
if tag="" |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
270 |
then log ("Proved: " ^ space_implode " " (map str_of_pos re_posns)) |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
271 |
else () |
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
272 |
) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
273 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
274 |
fun log_min_data log (succs, ab_ratios) = |
32609 | 275 |
(log ("Number of successful minimizations: " ^ string_of_int succs); |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
276 |
log ("After/before ratios: " ^ string_of_int ab_ratios) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
277 |
) |
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
278 |
|
32521 | 279 |
in |
280 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
281 |
fun log_data id log (Data {sh, min, re_u, re_m, re_uft, re_mft, mini}) = |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
282 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
283 |
val ShData {calls=sh_calls, ...} = sh |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
284 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
285 |
fun app_if (ReData {calls, ...}) f = if calls > 0 then f () else () |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
286 |
fun log_re tag m = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
287 |
log_re_data log tag sh_calls (tuple_of_re_data m) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
288 |
fun log_reconstructor (tag1, m1) (tag2, m2) = app_if m1 (fn () => |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
289 |
(log_re tag1 m1; log ""; app_if m2 (fn () => log_re tag2 m2))) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
290 |
in |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
291 |
if sh_calls > 0 |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
292 |
then |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
293 |
(log ("\n\n\nReport #" ^ string_of_int id ^ ":\n"); |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
294 |
log_sh_data log (tuple_of_sh_data sh); |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
295 |
log ""; |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
296 |
if not mini |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
297 |
then log_reconstructor ("", re_u) ("fully-typed ", re_uft) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
298 |
else |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
299 |
app_if re_u (fn () => |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
300 |
(log_reconstructor ("unminimized ", re_u) ("unminimized fully-typed ", re_uft); |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
301 |
log ""; |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
302 |
app_if re_m (fn () => |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
303 |
(log_min_data log (tuple_of_min_data min); log ""; |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
304 |
log_reconstructor ("", re_m) ("fully-typed ", re_mft)))))) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
305 |
else () |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
306 |
end |
32521 | 307 |
|
308 |
end |
|
309 |
||
310 |
||
311 |
(* Warning: we implicitly assume single-threaded execution here! *) |
|
32740 | 312 |
val data = Unsynchronized.ref ([] : (int * data) list) |
32521 | 313 |
|
32740 | 314 |
fun init id thy = (Unsynchronized.change data (cons (id, empty_data)); thy) |
32567
de411627a985
explicitly export type abbreviations (as usual in SML97);
wenzelm
parents:
32564
diff
changeset
|
315 |
fun done id ({log, ...}: Mirabelle.done_args) = |
32521 | 316 |
AList.lookup (op =) (!data) id |
317 |
|> Option.map (log_data id log) |
|
318 |
|> K () |
|
319 |
||
32740 | 320 |
fun change_data id f = (Unsynchronized.change data (AList.map_entry (op =) id f); ()) |
32521 | 321 |
|
322 |
||
42444
8e5438dc70bb
cleanup: get rid of "may_slice" arguments without changing semantics
blanchet
parents:
42443
diff
changeset
|
323 |
fun get_prover ctxt args = |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
324 |
let |
40062 | 325 |
fun default_prover_name () = |
40069 | 326 |
hd (#provers (Sledgehammer_Isar.default_params ctxt [])) |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
327 |
handle Empty => error "No ATP available." |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
328 |
fun get_prover name = |
43021 | 329 |
(name, Sledgehammer_Run.get_minimizing_prover ctxt |
330 |
Sledgehammer_Provers.Normal name) |
|
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
331 |
in |
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
332 |
(case AList.lookup (op =) args proverK of |
40062 | 333 |
SOME name => get_prover name |
334 |
| NONE => get_prover (default_prover_name ())) |
|
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
335 |
end |
32525 | 336 |
|
43088 | 337 |
type locality = ATP_Translate.locality |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
338 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
339 |
(* hack *) |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
340 |
fun reconstructor_from_msg args msg = |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
341 |
(case AList.lookup (op =) args reconstructorK of |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
342 |
SOME name => name |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
343 |
| NONE => |
43228
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
344 |
if String.isSubstring "metis (full_types)" msg then "metis (full_types)" |
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
345 |
else if String.isSubstring "metis (no_types)" msg then "metis (no_types)" |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
346 |
else if String.isSubstring "metis" msg then "metis" |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
347 |
else "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
|
348 |
|
32521 | 349 |
local |
350 |
||
32536 | 351 |
datatype sh_result = |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
352 |
SH_OK of int * int * (string * locality) list | |
32536 | 353 |
SH_FAIL of int * int | |
354 |
SH_ERROR |
|
355 |
||
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
356 |
fun run_sh prover_name prover type_sys max_relevant slicing e_weight_method spass_force_sos |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
357 |
vampire_force_sos hard_timeout timeout dir st = |
32521 | 358 |
let |
38998 | 359 |
val {context = ctxt, facts = chained_ths, goal} = Proof.goal st |
360 |
val i = 1 |
|
41337
263fe1670067
mechanism to keep SMT input and output files around in Mirabelle
blanchet
parents:
41276
diff
changeset
|
361 |
fun change_dir (SOME dir) = |
263fe1670067
mechanism to keep SMT input and output files around in Mirabelle
blanchet
parents:
41276
diff
changeset
|
362 |
Config.put Sledgehammer_Provers.dest_dir dir |
263fe1670067
mechanism to keep SMT input and output files around in Mirabelle
blanchet
parents:
41276
diff
changeset
|
363 |
#> Config.put SMT_Config.debug_files |
43088 | 364 |
(dir ^ "/" ^ Name.desymbolize false (ATP_Util.timestamp ()) ^ "_" |
41338 | 365 |
^ serial_string ()) |
39321 | 366 |
| change_dir NONE = I |
367 |
val st' = |
|
368 |
st |> Proof.map_context |
|
369 |
(change_dir dir |
|
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
370 |
#> (Option.map (Config.put ATP_Systems.e_weight_method) |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
371 |
e_weight_method |> the_default I) |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
372 |
#> (Option.map (Config.put ATP_Systems.spass_force_sos) |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
373 |
spass_force_sos |> the_default I) |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
374 |
#> (Option.map (Config.put ATP_Systems.vampire_force_sos) |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
375 |
vampire_force_sos |> the_default I) |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
376 |
#> Config.put Sledgehammer_Provers.measure_run_time true) |
42642 | 377 |
val params as {relevance_thresholds, max_relevant, slicing, ...} = |
40069 | 378 |
Sledgehammer_Isar.default_params ctxt |
40554
ff446d5e9a62
turn on Sledgehammer verbosity so we can track down crashes
blanchet
parents:
40526
diff
changeset
|
379 |
[("verbose", "true"), |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
380 |
("type_sys", type_sys), |
41752 | 381 |
("max_relevant", max_relevant), |
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
382 |
("slicing", slicing), |
41491 | 383 |
("timeout", string_of_int timeout)] |
40062 | 384 |
val default_max_relevant = |
42443
724e612ba248
implemented general slicing for ATPs, especially E 1.2w and above
blanchet
parents:
42361
diff
changeset
|
385 |
Sledgehammer_Provers.default_max_relevant_for_prover ctxt slicing |
724e612ba248
implemented general slicing for ATPs, especially E 1.2w and above
blanchet
parents:
42361
diff
changeset
|
386 |
prover_name |
42952
96f62b77748f
tuning -- the "appropriate" terminology is inspired from TPTP
blanchet
parents:
42944
diff
changeset
|
387 |
val is_appropriate_prop = |
96f62b77748f
tuning -- the "appropriate" terminology is inspired from TPTP
blanchet
parents:
42944
diff
changeset
|
388 |
Sledgehammer_Provers.is_appropriate_prop_for_prover ctxt prover_name |
40369
53dca3bd4250
use the SMT integration's official list of built-ins
blanchet
parents:
40301
diff
changeset
|
389 |
val is_built_in_const = |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
390 |
Sledgehammer_Provers.is_built_in_const_for_prover ctxt prover_name |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40694
diff
changeset
|
391 |
val relevance_fudge = |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
392 |
Sledgehammer_Provers.relevance_fudge_for_prover ctxt prover_name |
40070
bdb890782d4a
replaced references with proper record that's threaded through
blanchet
parents:
40069
diff
changeset
|
393 |
val relevance_override = {add = [], del = [], only = false} |
43088 | 394 |
val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal i |
32574
719426c9e1eb
added hard timeout for sledgehammer based on elapsed time (no need to trust ATP's timeout handling);
boehmes
parents:
32571
diff
changeset
|
395 |
val time_limit = |
719426c9e1eb
added hard timeout for sledgehammer based on elapsed time (no need to trust ATP's timeout handling);
boehmes
parents:
32571
diff
changeset
|
396 |
(case hard_timeout of |
719426c9e1eb
added hard timeout for sledgehammer based on elapsed time (no need to trust ATP's timeout handling);
boehmes
parents:
32571
diff
changeset
|
397 |
NONE => I |
719426c9e1eb
added hard timeout for sledgehammer based on elapsed time (no need to trust ATP's timeout handling);
boehmes
parents:
32571
diff
changeset
|
398 |
| SOME secs => TimeLimit.timeLimit (Time.fromSeconds secs)) |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
399 |
fun failed failure = |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
400 |
({outcome = SOME failure, used_facts = [], run_time_in_msecs = NONE, |
43166 | 401 |
preplay = K (ATP_Reconstruct.Failed_to_Play ATP_Reconstruct.Metis), |
43261
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
402 |
message = K "", message_tail = ""}, ~1) |
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
403 |
val ({outcome, used_facts, run_time_in_msecs, preplay, message, |
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
404 |
message_tail} : Sledgehammer_Provers.prover_result, |
41275 | 405 |
time_isa) = time_limit (Mirabelle.cpu_time (fn () => |
406 |
let |
|
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
407 |
val _ = if is_appropriate_prop concl_t then () |
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
408 |
else raise Fail "inappropriate" |
41275 | 409 |
val facts = |
43351
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
410 |
Sledgehammer_Filter.nearly_all_facts ctxt relevance_override |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
411 |
chained_ths hyp_ts concl_t |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
412 |
|> filter (is_appropriate_prop o prop_of o snd) |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
413 |
|> Sledgehammer_Filter.relevant_facts ctxt relevance_thresholds |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
414 |
(the_default default_max_relevant max_relevant) |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
415 |
is_built_in_const relevance_fudge relevance_override |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43261
diff
changeset
|
416 |
chained_ths hyp_ts concl_t |
41275 | 417 |
val problem = |
418 |
{state = st', goal = goal, subgoal = i, |
|
419 |
subgoal_count = Sledgehammer_Util.subgoal_count st, |
|
420 |
facts = facts |> map Sledgehammer_Provers.Untranslated_Fact, |
|
41741 | 421 |
smt_filter = NONE} |
43051 | 422 |
in prover params (K (K "")) problem end)) () |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
423 |
handle TimeLimit.TimeOut => failed ATP_Proof.TimedOut |
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
424 |
| Fail "inappropriate" => failed ATP_Proof.Inappropriate |
40374
443b426e05ea
make Mirabelle work correctly if the prover (e.g. the SMT solver) returns no timing information
blanchet
parents:
40372
diff
changeset
|
425 |
val time_prover = run_time_in_msecs |> the_default ~1 |
43261
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
426 |
val msg = message (preplay ()) ^ message_tail |
32521 | 427 |
in |
36405 | 428 |
case outcome of |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
429 |
NONE => (msg, SH_OK (time_isa, time_prover, used_facts)) |
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
430 |
| SOME _ => (msg, SH_FAIL (time_isa, time_prover)) |
32521 | 431 |
end |
37994
b04307085a09
make TPTP generator accept full first-order formulas
blanchet
parents:
37631
diff
changeset
|
432 |
handle ERROR msg => ("error: " ^ msg, SH_ERROR) |
32521 | 433 |
|
32454
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
434 |
fun thms_of_name ctxt name = |
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
435 |
let |
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36959
diff
changeset
|
436 |
val lex = Keyword.get_lexicons |
42361 | 437 |
val get = maps (Proof_Context.get_fact ctxt o fst) |
32454
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
438 |
in |
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
439 |
Source.of_string name |
40526 | 440 |
|> Symbol.source |
36959
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
36954
diff
changeset
|
441 |
|> Token.source {do_recover=SOME false} lex Position.start |
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
36954
diff
changeset
|
442 |
|> Token.source_proper |
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
wenzelm
parents:
36954
diff
changeset
|
443 |
|> Source.source Token.stopper (Parse_Spec.xthms1 >> get) NONE |
32454
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
444 |
|> Source.exhaust |
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
445 |
end |
32452
d84edd022efe
apply metis with found theorems in case sledgehammer was successful
boehmes
parents:
32434
diff
changeset
|
446 |
|
32498
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
447 |
in |
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
448 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
449 |
fun run_sledgehammer trivial args reconstructor named_thms id ({pre=st, log, ...}: Mirabelle.run_args) = |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
450 |
let |
39340 | 451 |
val triv_str = if trivial then "[T] " else "" |
32536 | 452 |
val _ = change_data id inc_sh_calls |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
453 |
val _ = if trivial then () else change_data id inc_sh_nontriv_calls |
42444
8e5438dc70bb
cleanup: get rid of "may_slice" arguments without changing semantics
blanchet
parents:
42443
diff
changeset
|
454 |
val (prover_name, prover) = get_prover (Proof.context_of st) args |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
455 |
val type_sys = AList.lookup (op =) args type_sysK |> the_default "smart" |
41752 | 456 |
val max_relevant = AList.lookup (op =) args max_relevantK |> the_default "smart" |
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
457 |
val slicing = AList.lookup (op =) args slicingK |> the_default "true" |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
458 |
val e_weight_method = AList.lookup (op =) args e_weight_methodK |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
459 |
val spass_force_sos = AList.lookup (op =) args spass_force_sosK |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
460 |
|> Option.map (curry (op <>) "false") |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
461 |
val vampire_force_sos = AList.lookup (op =) args vampire_force_sosK |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
462 |
|> Option.map (curry (op <>) "false") |
32525 | 463 |
val dir = AList.lookup (op =) args keepK |
32541 | 464 |
val timeout = Mirabelle.get_int_setting args (prover_timeoutK, 30) |
41268 | 465 |
(* always use a hard timeout, but give some slack so that the automatic |
466 |
minimizer has a chance to do its magic *) |
|
467 |
val hard_timeout = SOME (2 * timeout) |
|
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
468 |
val (msg, result) = |
42725
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
469 |
run_sh prover_name prover type_sys max_relevant slicing e_weight_method spass_force_sos |
64dea91bbe0e
added "force_sos" options to control SPASS's and Vampire's use of SOS in experiments + added corresponding Mirabelle options
blanchet
parents:
42642
diff
changeset
|
470 |
vampire_force_sos hard_timeout timeout dir st |
32525 | 471 |
in |
32536 | 472 |
case result of |
40062 | 473 |
SH_OK (time_isa, time_prover, names) => |
38700 | 474 |
let |
43088 | 475 |
fun get_thms (_, ATP_Translate.Chained) = NONE |
38826 | 476 |
| get_thms (name, loc) = |
477 |
SOME ((name, loc), thms_of_name (Proof.context_of st) name) |
|
32525 | 478 |
in |
32818 | 479 |
change_data id inc_sh_success; |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
480 |
if trivial then () else change_data id inc_sh_nontriv_success; |
32818 | 481 |
change_data id (inc_sh_lemmas (length names)); |
482 |
change_data id (inc_sh_max_lems (length names)); |
|
483 |
change_data id (inc_sh_time_isa time_isa); |
|
40062 | 484 |
change_data id (inc_sh_time_prover time_prover); |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
485 |
reconstructor := reconstructor_from_msg args msg; |
38826 | 486 |
named_thms := SOME (map_filter get_thms names); |
39340 | 487 |
log (sh_tag id ^ triv_str ^ "succeeded (" ^ string_of_int time_isa ^ "+" ^ |
40062 | 488 |
string_of_int time_prover ^ ") [" ^ prover_name ^ "]:\n" ^ msg) |
32525 | 489 |
end |
40062 | 490 |
| SH_FAIL (time_isa, time_prover) => |
32536 | 491 |
let |
492 |
val _ = change_data id (inc_sh_time_isa time_isa) |
|
40062 | 493 |
val _ = change_data id (inc_sh_time_prover_fail time_prover) |
39340 | 494 |
in log (sh_tag id ^ triv_str ^ "failed: " ^ msg) end |
32536 | 495 |
| SH_ERROR => log (sh_tag id ^ "failed: " ^ msg) |
32525 | 496 |
end |
497 |
||
498 |
end |
|
499 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
500 |
fun run_minimize args reconstructor named_thms id |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
501 |
({pre=st, log, ...}: Mirabelle.run_args) = |
32525 | 502 |
let |
40069 | 503 |
val ctxt = Proof.context_of st |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
504 |
val n0 = length (these (!named_thms)) |
42444
8e5438dc70bb
cleanup: get rid of "may_slice" arguments without changing semantics
blanchet
parents:
42443
diff
changeset
|
505 |
val (prover_name, _) = get_prover ctxt args |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
506 |
val type_sys = AList.lookup (op =) args type_sysK |> the_default "smart" |
32525 | 507 |
val timeout = |
508 |
AList.lookup (op =) args minimize_timeoutK |
|
40627
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
wenzelm
parents:
40554
diff
changeset
|
509 |
|> Option.map (fst o read_int o raw_explode) (* FIXME Symbol.explode (?) *) |
32525 | 510 |
|> the_default 5 |
43064
b6e61d22fa61
made "explicit_apply" smarter -- no need to force explicit applications in minimizer on all constants, better do it more fine granularly
blanchet
parents:
43052
diff
changeset
|
511 |
val params = Sledgehammer_Isar.default_params ctxt |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
512 |
[("provers", prover_name), |
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
513 |
("verbose", "true"), |
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
514 |
("type_sys", type_sys), |
41491 | 515 |
("timeout", string_of_int timeout)] |
37587 | 516 |
val minimize = |
41742
11e862c68b40
automatically minimize Z3-as-an-ATP proofs (cf. CVC3 and Yices)
blanchet
parents:
41741
diff
changeset
|
517 |
Sledgehammer_Minimize.minimize_facts prover_name params |
43064
b6e61d22fa61
made "explicit_apply" smarter -- no need to force explicit applications in minimizer on all constants, better do it more fine granularly
blanchet
parents:
43052
diff
changeset
|
518 |
true 1 (Sledgehammer_Util.subgoal_count st) |
32525 | 519 |
val _ = log separator |
43261
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
520 |
val (used_facts, (preplay, message, message_tail)) = |
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
521 |
minimize st (these (!named_thms)) |
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
522 |
val msg = message (preplay ()) ^ message_tail |
32525 | 523 |
in |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
524 |
case used_facts of |
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
525 |
SOME named_thms' => |
32609 | 526 |
(change_data id inc_min_succs; |
527 |
change_data id (inc_min_ab_ratios ((100 * length named_thms') div n0)); |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
528 |
if length named_thms' = n0 |
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
529 |
then log (minimize_tag id ^ "already minimal") |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
530 |
else (reconstructor := reconstructor_from_msg args msg; |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
531 |
named_thms := SOME named_thms'; |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
532 |
log (minimize_tag id ^ "succeeded:\n" ^ msg)) |
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
533 |
) |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
534 |
| NONE => log (minimize_tag id ^ "failed: " ^ msg) |
32525 | 535 |
end |
536 |
||
537 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
538 |
fun run_reconstructor trivial full m name reconstructor named_thms id |
32567
de411627a985
explicitly export type abbreviations (as usual in SML97);
wenzelm
parents:
32564
diff
changeset
|
539 |
({pre=st, timeout, log, pos, ...}: Mirabelle.run_args) = |
32525 | 540 |
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
|
541 |
fun do_reconstructor thms ctxt = |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
542 |
(if !reconstructor = "sledgehammer_tac" then |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
543 |
(fn ctxt => fn thms => |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
544 |
Method.insert_tac thms THEN' |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
545 |
Sledgehammer_Tactics.sledgehammer_as_unsound_oracle_tac ctxt) |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
546 |
else if !reconstructor = "smt" then |
41154 | 547 |
SMT_Solver.smt_tac |
43228
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
548 |
else if full orelse !reconstructor = "metis (full_types)" then |
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
549 |
Metis_Tactics.metis_tac [Metis_Tactics.full_type_sys] |
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
550 |
else if !reconstructor = "metis (no_types)" then |
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43212
diff
changeset
|
551 |
Metis_Tactics.metis_tac [Metis_Tactics.no_type_sys] |
41154 | 552 |
else |
43212 | 553 |
Metis_Tactics.metis_tac []) ctxt thms |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
554 |
fun apply_reconstructor thms = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
555 |
Mirabelle.can_apply timeout (do_reconstructor thms) st |
32521 | 556 |
|
557 |
fun with_time (false, t) = "failed (" ^ string_of_int t ^ ")" |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
558 |
| with_time (true, t) = (change_data id (inc_reconstructor_success m); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
559 |
if trivial then () |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
560 |
else change_data id (inc_reconstructor_nontriv_success m); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
561 |
change_data id (inc_reconstructor_lemmas m (length named_thms)); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
562 |
change_data id (inc_reconstructor_time m t); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
563 |
change_data id (inc_reconstructor_posns m (pos, trivial)); |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
564 |
if name = "proof" then change_data id (inc_reconstructor_proofs m) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
565 |
else (); |
32521 | 566 |
"succeeded (" ^ string_of_int t ^ ")") |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
567 |
fun timed_reconstructor thms = |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
568 |
(with_time (Mirabelle.cpu_time apply_reconstructor thms), true) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
569 |
handle TimeLimit.TimeOut => (change_data id (inc_reconstructor_timeout m); |
34052 | 570 |
("timeout", false)) |
571 |
| ERROR msg => ("error: " ^ msg, false) |
|
32521 | 572 |
|
32525 | 573 |
val _ = log separator |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
574 |
val _ = change_data id (inc_reconstructor_calls m) |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
575 |
val _ = if trivial then () |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
576 |
else change_data id (inc_reconstructor_nontriv_calls m) |
32521 | 577 |
in |
32525 | 578 |
maps snd named_thms |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
579 |
|> timed_reconstructor |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
580 |
|>> log o prefix (reconstructor_tag reconstructor id) |
34052 | 581 |
|> snd |
32521 | 582 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
583 |
|
41276
285aea0c153c
two layers of timeouts seem to be less reliable than a single layer
blanchet
parents:
41275
diff
changeset
|
584 |
val try_timeout = seconds 5.0 |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
585 |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
586 |
fun sledgehammer_action args id (st as {pre, name, ...}: Mirabelle.run_args) = |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
587 |
let val goal = Thm.major_prem_of (#goal (Proof.goal pre)) in |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
588 |
if can Logic.dest_conjunction goal orelse can Logic.dest_equals goal |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
589 |
then () else |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
590 |
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
|
591 |
val reconstructor = Unsynchronized.ref "" |
38700 | 592 |
val named_thms = |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
593 |
Unsynchronized.ref (NONE : ((string * locality) * thm list) list option) |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
594 |
val minimize = AList.defined (op =) args minimizeK |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
595 |
val metis_ft = AList.defined (op =) args metis_ftK |
43020
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43004
diff
changeset
|
596 |
val trivial = |
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43004
diff
changeset
|
597 |
Try_Methods.try_methods (SOME try_timeout) ([], [], [], []) pre |
41276
285aea0c153c
two layers of timeouts seem to be less reliable than a single layer
blanchet
parents:
41275
diff
changeset
|
598 |
handle TimeLimit.TimeOut => false |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
599 |
fun apply_reconstructor m1 m2 = |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
600 |
if metis_ft |
34052 | 601 |
then |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
602 |
if not (Mirabelle.catch_result (reconstructor_tag reconstructor) false |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
603 |
(run_reconstructor trivial false m1 name reconstructor |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
604 |
(these (!named_thms))) id st) |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
605 |
then |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
606 |
(Mirabelle.catch_result (reconstructor_tag reconstructor) false |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
607 |
(run_reconstructor trivial true m2 name reconstructor |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
608 |
(these (!named_thms))) id st; ()) |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
609 |
else () |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
610 |
else |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
611 |
(Mirabelle.catch_result (reconstructor_tag reconstructor) false |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
612 |
(run_reconstructor trivial false m1 name reconstructor |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
613 |
(these (!named_thms))) id st; ()) |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
614 |
in |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
615 |
change_data id (set_mini minimize); |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
616 |
Mirabelle.catch sh_tag (run_sledgehammer trivial args reconstructor |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
617 |
named_thms) id st; |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
618 |
if is_some (!named_thms) |
32612 | 619 |
then |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
620 |
(apply_reconstructor Unminimized UnminimizedFT; |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
621 |
if minimize andalso not (null (these (!named_thms))) |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
622 |
then |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
623 |
(Mirabelle.catch minimize_tag |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
624 |
(run_minimize args reconstructor named_thms) id st; |
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
625 |
apply_reconstructor Minimized MinimizedFT) |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
626 |
else ()) |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
627 |
else () |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
628 |
end |
32818 | 629 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
630 |
|
32511 | 631 |
fun invoke args = |
43569
b342cd125533
removed "full_types" option from Sledgehammer, now that virtually sound encodings are used as the default anyway
blanchet
parents:
43351
diff
changeset
|
632 |
Mirabelle.register (init, sledgehammer_action args, done) |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
633 |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
634 |
end |