author | blanchet |
Wed, 18 Jul 2012 08:44:03 +0200 | |
changeset 48292 | 7fcee834c7f5 |
parent 48289 | 6b65f1ad0e4b |
child 48293 | 914ca0827804 |
permissions | -rw-r--r-- |
47847 | 1 |
(* Title: HOL/Mirabelle/Tools/mirabelle_sledgehammer.ML |
32564 | 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 |
|
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
|
8 |
(*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
|
9 |
(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
|
10 |
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
|
11 |
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
|
12 |
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
|
13 |
*) |
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 |
(*NOTE: descriptions mention parameters (particularly NAME) without a defined range.*) |
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 |
val proverK = "prover" (*=NAME: name of the external prover to call*) |
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 |
val prover_timeoutK = "prover_timeout" (*=TIME: timeout for invoked ATP (seconds of process time)*) |
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 |
val keepK = "keep" (*=PATH: path where to keep temporary files created by sledgehammer*) |
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 minimizeK = "minimize" (*: enable minimization of theorem set found by sledgehammer*) |
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 |
(*refers to minimization attempted by Mirabelle*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
20 |
val minimize_timeoutK = "minimize_timeout" (*=TIME: timeout for each minimization step (seconds of*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
21 |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
22 |
val reconstructorK = "reconstructor" (*=NAME: how to reconstruct proofs (ie. using metis/smt)*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
23 |
val metis_ftK = "metis_ft" (*: apply metis with fully-typed encoding to the theorems found by sledgehammer*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
24 |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
25 |
val max_relevantK = "max_relevant" (*=NUM: max. relevant clauses to use*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
26 |
val max_callsK = "max_calls" (*=NUM: max. no. of calls to sledgehammer*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
27 |
val preplay_timeoutK = "preplay_timeout" (*=TIME: timeout for finding reconstructed proof*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
28 |
val sh_minimizeK = "sh_minimize" (*: instruct sledgehammer to run its minimizer*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
29 |
|
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
30 |
val check_trivialK = "check_trivial" (*: check if goals are "trivial" (false by default)*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
31 |
val type_encK = "type_enc" (*=STRING: type encoding scheme*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
32 |
val lam_transK = "lam_trans" (*=STRING: lambda translation scheme*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
33 |
val strictK = "strict" (*=BOOL: run in strict mode*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
34 |
val sliceK = "slice" (*=BOOL: allow sledgehammer-level strategy-scheduling*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
35 |
val uncurried_aliasesK = "uncurried_aliases" (*=SMART_BOOL: use fresh function names to alias curried applications*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
36 |
val e_selection_heuristicK = "e_selection_heuristic" (*: FIXME*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
37 |
val term_orderK = "term_order" (*: FIXME*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
38 |
val force_sosK = "force_sos" (*: use SOS*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
39 |
val max_new_mono_instancesK = "max_new_mono_instances" (*=NUM: max. new monomorphic instances*) |
24d8c9e9dae4
Mirabelle's 'usage' description relating to Sledgehammer now synchs with the ML code of the Mirabelle-Sledgehammer action
sultana
parents:
47477
diff
changeset
|
40 |
val max_mono_itersK = "max_mono_iters" (*=NUM: max. iterations of monomorphiser*) |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
41 |
|
32521 | 42 |
fun sh_tag id = "#" ^ string_of_int id ^ " sledgehammer: " |
32525 | 43 |
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
|
44 |
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
|
45 |
"#" ^ string_of_int id ^ " " ^ (!reconstructor) ^ " (sledgehammer): " |
32521 | 46 |
|
32525 | 47 |
val separator = "-----" |
48 |
||
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
49 |
(*FIXME sensible to have Mirabelle-level Sledgehammer defaults?*) |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
50 |
(*defaults used in this Mirabelle action*) |
46825
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
51 |
val preplay_timeout_default = "4" |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
52 |
val lam_trans_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
53 |
val uncurried_aliases_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
54 |
val type_enc_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
55 |
val strict_default = "false" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
56 |
val max_relevant_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
57 |
val slice_default = "true" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
58 |
val max_calls_default = "10000000" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
59 |
val trivial_default = "false" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
60 |
val minimize_timeout_default = 5 |
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
|
61 |
|
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
|
62 |
(*If a key is present in args then augment a list with its pair*) |
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
|
63 |
(*This is used to avoid fixing default values at the Mirabelle level, and |
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
|
64 |
instead use the default values of the tool (Sledgehammer in this case).*) |
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
|
65 |
fun available_parameter args key label list = |
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
|
66 |
let |
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
|
67 |
val value = AList.lookup (op =) args key |
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
|
68 |
in if is_some value then (label, the value) :: list else list end |
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
|
69 |
|
32521 | 70 |
|
32549 | 71 |
datatype sh_data = ShData of { |
72 |
calls: int, |
|
73 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
74 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
75 |
nontriv_success: int, |
32585 | 76 |
lemmas: int, |
32818 | 77 |
max_lems: int, |
32549 | 78 |
time_isa: int, |
40062 | 79 |
time_prover: int, |
80 |
time_prover_fail: int} |
|
32549 | 81 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
82 |
datatype re_data = ReData of { |
32549 | 83 |
calls: int, |
84 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
85 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
86 |
nontriv_success: int, |
32676 | 87 |
proofs: int, |
32549 | 88 |
time: int, |
32550 | 89 |
timeout: int, |
32990 | 90 |
lemmas: int * int * int, |
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
91 |
posns: (Position.T * bool) list |
32550 | 92 |
} |
32549 | 93 |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
94 |
datatype min_data = MinData of { |
32609 | 95 |
succs: int, |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
96 |
ab_ratios: int |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
97 |
} |
32521 | 98 |
|
32818 | 99 |
fun make_sh_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
100 |
(calls,success,nontriv_calls,nontriv_success,lemmas,max_lems,time_isa, |
40062 | 101 |
time_prover,time_prover_fail) = |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
102 |
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
|
103 |
nontriv_success=nontriv_success, lemmas=lemmas, max_lems=max_lems, |
40062 | 104 |
time_isa=time_isa, time_prover=time_prover, |
105 |
time_prover_fail=time_prover_fail} |
|
32521 | 106 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
107 |
fun make_min_data (succs, ab_ratios) = |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
108 |
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
|
109 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
nontriv_success=nontriv_success, proofs=proofs, time=time, |
32990 | 114 |
timeout=timeout, lemmas=lemmas, posns=posns} |
32549 | 115 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
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
|
119 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
120 |
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
|
121 |
lemmas, max_lems, time_isa, |
40062 | 122 |
time_prover, time_prover_fail}) = (calls, success, nontriv_calls, |
123 |
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
|
124 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
125 |
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
|
126 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
|
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 |
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
|
133 |
Unminimized | Minimized | UnminimizedFT | MinimizedFT |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
134 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
135 |
datatype data = Data of { |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
136 |
sh: sh_data, |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
mini: bool (* with minimization *) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
143 |
} |
32521 | 144 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
145 |
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
|
146 |
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
|
147 |
mini=mini} |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
148 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
149 |
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
|
150 |
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
|
151 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
in make_data (sh, min', re_u, re_m, re_uft, re_mft, mini) end |
32521 | 159 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
160 |
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
|
161 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
162 |
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
|
163 |
| 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
|
164 |
| 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
|
165 |
| map_me g MinimizedFT (u, m, uft, mft) = (u, m, uft, g mft) |
32521 | 166 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
167 |
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
|
168 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
169 |
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
|
170 |
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
|
171 |
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
|
172 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
173 |
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
|
174 |
make_data (sh, min, re_u, re_m, re_uft, re_mft, mini) |
32990 | 175 |
|
176 |
fun inc_max (n:int) (s,sos,m) = (s+n, sos + n*n, Int.max(m,n)); |
|
32521 | 177 |
|
32818 | 178 |
val inc_sh_calls = map_sh_data |
40062 | 179 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
180 |
=> (calls + 1, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail)) |
|
32549 | 181 |
|
32818 | 182 |
val inc_sh_success = map_sh_data |
40062 | 183 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
184 |
=> (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
|
185 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
186 |
val inc_sh_nontriv_calls = map_sh_data |
40062 | 187 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
188 |
=> (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
|
189 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
190 |
val inc_sh_nontriv_success = map_sh_data |
40062 | 191 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
192 |
=> (calls, success, nontriv_calls, nontriv_success + 1, lemmas,max_lems, time_isa, time_prover, time_prover_fail)) |
|
32585 | 193 |
|
32818 | 194 |
fun inc_sh_lemmas n = map_sh_data |
40062 | 195 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
196 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas+n,max_lems,time_isa,time_prover,time_prover_fail)) |
|
32521 | 197 |
|
32818 | 198 |
fun inc_sh_max_lems n = map_sh_data |
40062 | 199 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
200 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,Int.max(max_lems,n),time_isa,time_prover,time_prover_fail)) |
|
32549 | 201 |
|
32818 | 202 |
fun inc_sh_time_isa t = map_sh_data |
40062 | 203 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
204 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa + t,time_prover,time_prover_fail)) |
|
32818 | 205 |
|
40062 | 206 |
fun inc_sh_time_prover t = map_sh_data |
207 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
208 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover + t,time_prover_fail)) |
|
32521 | 209 |
|
40062 | 210 |
fun inc_sh_time_prover_fail t = map_sh_data |
211 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
212 |
=> (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
|
213 |
|
32818 | 214 |
val inc_min_succs = map_min_data |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
215 |
(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
|
216 |
|
32818 | 217 |
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
|
218 |
(fn (succs, ab_ratios) => (succs, ab_ratios+r)) |
32549 | 219 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
220 |
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
|
221 |
(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
|
222 |
=> (calls + 1, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas,posns)) |
32533 | 223 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
224 |
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
|
225 |
(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
|
226 |
=> (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
|
227 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
228 |
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
|
229 |
(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
|
230 |
=> (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
|
231 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
232 |
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
|
233 |
(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
|
234 |
=> (calls, success, nontriv_calls, nontriv_success + 1, proofs, time, timeout, lemmas,posns)) |
32676 | 235 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
236 |
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
|
237 |
(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
|
238 |
=> (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
|
239 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
240 |
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
|
241 |
(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
|
242 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time + t, timeout, lemmas,posns)) m |
32536 | 243 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
244 |
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
|
245 |
(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
|
246 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout + 1, lemmas,posns)) |
32549 | 247 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
248 |
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
|
249 |
(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
|
250 |
=> (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
|
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 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
|
253 |
(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
|
254 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas, pos::posns)) m |
32521 | 255 |
|
44090 | 256 |
val str0 = string_of_int o the_default 0 |
257 |
||
32521 | 258 |
local |
259 |
||
260 |
val str = string_of_int |
|
261 |
val str3 = Real.fmt (StringCvt.FIX (SOME 3)) |
|
262 |
fun percentage a b = string_of_int (a * 100 div b) |
|
263 |
fun time t = Real.fromInt t / 1000.0 |
|
264 |
fun avg_time t n = |
|
265 |
if n > 0 then (Real.fromInt t / 1000.0) / Real.fromInt n else 0.0 |
|
266 |
||
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
267 |
fun log_sh_data log |
40062 | 268 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail) = |
32818 | 269 |
(log ("Total number of sledgehammer calls: " ^ str calls); |
270 |
log ("Number of successful sledgehammer calls: " ^ str success); |
|
271 |
log ("Number of sledgehammer lemmas: " ^ str lemmas); |
|
272 |
log ("Max number of sledgehammer lemmas: " ^ str max_lems); |
|
273 |
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
|
274 |
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
|
275 |
log ("Number of successful nontrivial sledgehammer calls: " ^ str nontriv_success); |
32818 | 276 |
log ("Total time for sledgehammer calls (Isabelle): " ^ str3 (time time_isa)); |
40062 | 277 |
log ("Total time for successful sledgehammer calls (ATP): " ^ str3 (time time_prover)); |
278 |
log ("Total time for failed sledgehammer calls (ATP): " ^ str3 (time time_prover_fail)); |
|
32536 | 279 |
log ("Average time for sledgehammer calls (Isabelle): " ^ |
32818 | 280 |
str3 (avg_time time_isa calls)); |
32533 | 281 |
log ("Average time for successful sledgehammer calls (ATP): " ^ |
40062 | 282 |
str3 (avg_time time_prover success)); |
32536 | 283 |
log ("Average time for failed sledgehammer calls (ATP): " ^ |
40062 | 284 |
str3 (avg_time time_prover_fail (calls - success))) |
32533 | 285 |
) |
32521 | 286 |
|
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
287 |
fun str_of_pos (pos, triv) = |
47728
6ee015f6ea4b
reintroduce file offsets in Mirabelle output, but make sure they are not influenced by the length of the path
blanchet
parents:
47532
diff
changeset
|
288 |
str0 (Position.line_of pos) ^ ":" ^ str0 (Position.offset_of pos) ^ |
44090 | 289 |
(if triv then "[T]" else "") |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
290 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
291 |
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
|
292 |
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
|
293 |
(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
|
294 |
(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
|
295 |
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
|
296 |
" (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
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
" (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
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
str3 (avg_time re_time re_success)); |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
308 |
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
|
309 |
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
|
310 |
else () |
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
311 |
) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
312 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
313 |
fun log_min_data log (succs, ab_ratios) = |
32609 | 314 |
(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
|
315 |
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
|
316 |
) |
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
317 |
|
32521 | 318 |
in |
319 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
320 |
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
|
321 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
322 |
val ShData {calls=sh_calls, ...} = sh |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
323 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
(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
|
329 |
in |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
330 |
if sh_calls > 0 |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
331 |
then |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
332 |
(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
|
333 |
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
|
334 |
log ""; |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
(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
|
340 |
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
|
341 |
app_if re_m (fn () => |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
342 |
(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
|
343 |
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
|
344 |
else () |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
345 |
end |
32521 | 346 |
|
347 |
end |
|
348 |
||
349 |
||
350 |
(* Warning: we implicitly assume single-threaded execution here! *) |
|
32740 | 351 |
val data = Unsynchronized.ref ([] : (int * data) list) |
32521 | 352 |
|
32740 | 353 |
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
|
354 |
fun done id ({log, ...}: Mirabelle.done_args) = |
32521 | 355 |
AList.lookup (op =) (!data) id |
356 |
|> Option.map (log_data id log) |
|
357 |
|> K () |
|
358 |
||
32740 | 359 |
fun change_data id f = (Unsynchronized.change data (AList.map_entry (op =) id f); ()) |
32521 | 360 |
|
361 |
||
42444
8e5438dc70bb
cleanup: get rid of "may_slice" arguments without changing semantics
blanchet
parents:
42443
diff
changeset
|
362 |
fun get_prover ctxt args = |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
363 |
let |
40062 | 364 |
fun default_prover_name () = |
40069 | 365 |
hd (#provers (Sledgehammer_Isar.default_params ctxt [])) |
47060
e2741ec9ae36
prefer explicitly qualified exception List.Empty;
wenzelm
parents:
47049
diff
changeset
|
366 |
handle List.Empty => error "No ATP available." |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
367 |
fun get_prover name = |
48250
1065c307fafe
further ML structure split to permit finer-grained loading/reordering (problem to solve: MaSh needs most of Sledgehammer)
blanchet
parents:
47974
diff
changeset
|
368 |
(name, Sledgehammer_Minimize.get_minimizing_prover ctxt |
43021 | 369 |
Sledgehammer_Provers.Normal name) |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
370 |
in |
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
371 |
(case AList.lookup (op =) args proverK of |
40062 | 372 |
SOME name => get_prover name |
373 |
| NONE => get_prover (default_prover_name ())) |
|
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
374 |
end |
32525 | 375 |
|
46340 | 376 |
type stature = ATP_Problem_Generate.stature |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
377 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
378 |
(* hack *) |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
379 |
fun reconstructor_from_msg args msg = |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
380 |
(case AList.lookup (op =) args reconstructorK of |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
381 |
SOME name => name |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
382 |
| NONE => |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
383 |
if String.isSubstring "metis (" msg then |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
384 |
msg |> Substring.full |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
385 |
|> Substring.position "metis (" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
386 |
|> snd |> Substring.position ")" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
387 |
|> fst |> Substring.string |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
388 |
|> suffix ")" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
389 |
else if String.isSubstring "metis" msg then |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
390 |
"metis" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
391 |
else |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
392 |
"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
|
393 |
|
32521 | 394 |
local |
395 |
||
32536 | 396 |
datatype sh_result = |
46340 | 397 |
SH_OK of int * int * (string * stature) list | |
32536 | 398 |
SH_FAIL of int * int | |
399 |
SH_ERROR |
|
400 |
||
46386 | 401 |
fun run_sh prover_name prover type_enc strict max_relevant slice lam_trans |
47049 | 402 |
uncurried_aliases e_selection_heuristic term_order force_sos |
403 |
hard_timeout timeout preplay_timeout sh_minimizeLST |
|
404 |
max_new_mono_instancesLST max_mono_itersLST dir pos st = |
|
32521 | 405 |
let |
38998 | 406 |
val {context = ctxt, facts = chained_ths, goal} = Proof.goal st |
407 |
val i = 1 |
|
44090 | 408 |
fun set_file_name (SOME dir) = |
41337
263fe1670067
mechanism to keep SMT input and output files around in Mirabelle
blanchet
parents:
41276
diff
changeset
|
409 |
Config.put Sledgehammer_Provers.dest_dir dir |
44090 | 410 |
#> Config.put Sledgehammer_Provers.problem_prefix |
44424 | 411 |
("prob_" ^ str0 (Position.line_of pos) ^ "__") |
41337
263fe1670067
mechanism to keep SMT input and output files around in Mirabelle
blanchet
parents:
41276
diff
changeset
|
412 |
#> Config.put SMT_Config.debug_files |
43088 | 413 |
(dir ^ "/" ^ Name.desymbolize false (ATP_Util.timestamp ()) ^ "_" |
41338 | 414 |
^ serial_string ()) |
44090 | 415 |
| set_file_name NONE = I |
39321 | 416 |
val st' = |
47030 | 417 |
st |
418 |
|> Proof.map_context |
|
419 |
(set_file_name dir |
|
47032 | 420 |
#> (Option.map (Config.put ATP_Systems.e_selection_heuristic) |
421 |
e_selection_heuristic |> the_default I) |
|
47049 | 422 |
#> (Option.map (Config.put ATP_Systems.term_order) |
423 |
term_order |> the_default I) |
|
47030 | 424 |
#> (Option.map (Config.put ATP_Systems.force_sos) |
425 |
force_sos |> the_default I)) |
|
48288
255c6e1fd505
rationalize relevance filter, slowing moving code from Iter to MaSh
blanchet
parents:
48250
diff
changeset
|
426 |
val params as {max_relevant, slice, ...} = |
40069 | 427 |
Sledgehammer_Isar.default_params ctxt |
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
|
428 |
([("verbose", "true"), |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43569
diff
changeset
|
429 |
("type_enc", type_enc), |
46386 | 430 |
("strict", strict), |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
431 |
("lam_trans", lam_trans |> the_default lam_trans_default), |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
432 |
("uncurried_aliases", uncurried_aliases |> the_default uncurried_aliases_default), |
41752 | 433 |
("max_relevant", max_relevant), |
45706 | 434 |
("slice", slice), |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
435 |
("timeout", string_of_int timeout), |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
436 |
("preplay_timeout", preplay_timeout)] |
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
|
437 |
|> sh_minimizeLST (*don't confuse the two minimization flags*) |
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
|
438 |
|> max_new_mono_instancesLST |
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
|
439 |
|> max_mono_itersLST) |
40062 | 440 |
val default_max_relevant = |
45706 | 441 |
Sledgehammer_Provers.default_max_relevant_for_prover ctxt slice |
42443
724e612ba248
implemented general slicing for ATPs, especially E 1.2w and above
blanchet
parents:
42361
diff
changeset
|
442 |
prover_name |
42952
96f62b77748f
tuning -- the "appropriate" terminology is inspired from TPTP
blanchet
parents:
42944
diff
changeset
|
443 |
val is_appropriate_prop = |
96f62b77748f
tuning -- the "appropriate" terminology is inspired from TPTP
blanchet
parents:
42944
diff
changeset
|
444 |
Sledgehammer_Provers.is_appropriate_prop_for_prover ctxt prover_name |
43088 | 445 |
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
|
446 |
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
|
447 |
(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
|
448 |
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
|
449 |
| SOME secs => TimeLimit.timeLimit (Time.fromSeconds secs)) |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
450 |
fun failed failure = |
45371 | 451 |
({outcome = SOME failure, used_facts = [], run_time = Time.zeroTime, |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
452 |
preplay = |
46320 | 453 |
K (ATP_Proof_Reconstruct.Failed_to_Play Sledgehammer_Provers.plain_metis), |
43261
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
454 |
message = K "", message_tail = ""}, ~1) |
45371 | 455 |
val ({outcome, used_facts, run_time, preplay, message, message_tail} |
456 |
: Sledgehammer_Provers.prover_result, |
|
41275 | 457 |
time_isa) = time_limit (Mirabelle.cpu_time (fn () => |
458 |
let |
|
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
459 |
val _ = if is_appropriate_prop concl_t then () |
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
460 |
else raise Fail "inappropriate" |
44625 | 461 |
val ho_atp = Sledgehammer_Provers.is_ho_atp ctxt prover_name |
41275 | 462 |
val facts = |
48288
255c6e1fd505
rationalize relevance filter, slowing moving code from Iter to MaSh
blanchet
parents:
48250
diff
changeset
|
463 |
Sledgehammer_Fact.nearly_all_facts ctxt ho_atp |
48292 | 464 |
Sledgehammer_Fact.no_fact_override chained_ths hyp_ts concl_t |
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
|
465 |
|> filter (is_appropriate_prop o prop_of o snd) |
48288
255c6e1fd505
rationalize relevance filter, slowing moving code from Iter to MaSh
blanchet
parents:
48250
diff
changeset
|
466 |
|> Sledgehammer_Filter_MaSh.relevant_facts ctxt params prover_name |
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
|
467 |
(the_default default_max_relevant max_relevant) |
48292 | 468 |
Sledgehammer_Fact.no_fact_override hyp_ts concl_t |
41275 | 469 |
val problem = |
470 |
{state = st', goal = goal, subgoal = i, |
|
471 |
subgoal_count = Sledgehammer_Util.subgoal_count st, |
|
48289 | 472 |
facts = facts |> map (apfst (apfst (fn name => name ()))) |
473 |
|> map Sledgehammer_Provers.Untranslated_Fact} |
|
45520 | 474 |
in prover params (K (K (K ""))) problem end)) () |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
475 |
handle TimeLimit.TimeOut => failed ATP_Proof.TimedOut |
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
476 |
| Fail "inappropriate" => failed ATP_Proof.Inappropriate |
45371 | 477 |
val time_prover = run_time |> Time.toMilliseconds |
43261
a4aeb26a6362
make sure that the message tail (timing + TPTP important message) is preserved upon automatic minimization
blanchet
parents:
43228
diff
changeset
|
478 |
val msg = message (preplay ()) ^ message_tail |
32521 | 479 |
in |
36405 | 480 |
case outcome of |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
481 |
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
|
482 |
| SOME _ => (msg, SH_FAIL (time_isa, time_prover)) |
32521 | 483 |
end |
37994
b04307085a09
make TPTP generator accept full first-order formulas
blanchet
parents:
37631
diff
changeset
|
484 |
handle ERROR msg => ("error: " ^ msg, SH_ERROR) |
32521 | 485 |
|
32454
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
486 |
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
|
487 |
let |
36960
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents:
36959
diff
changeset
|
488 |
val lex = Keyword.get_lexicons |
42361 | 489 |
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
|
490 |
in |
a1a5589207ad
Mirabelle: proper parsing of theorem names found by sledgehammer, respecting test intervals given along with file names
boehmes
parents:
32452
diff
changeset
|
491 |
Source.of_string name |
40526 | 492 |
|> 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
|
493 |
|> 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
|
494 |
|> 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
|
495 |
|> 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
|
496 |
|> 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
|
497 |
end |
32452
d84edd022efe
apply metis with found theorems in case sledgehammer was successful
boehmes
parents:
32434
diff
changeset
|
498 |
|
32498
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
499 |
in |
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
500 |
|
44090 | 501 |
fun run_sledgehammer trivial args reconstructor named_thms id |
502 |
({pre=st, log, pos, ...}: Mirabelle.run_args) = |
|
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
503 |
let |
39340 | 504 |
val triv_str = if trivial then "[T] " else "" |
32536 | 505 |
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
|
506 |
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
|
507 |
val (prover_name, prover) = get_prover (Proof.context_of st) args |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
508 |
val type_enc = AList.lookup (op =) args type_encK |> the_default type_enc_default |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
509 |
val strict = AList.lookup (op =) args strictK |> the_default strict_default |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
510 |
val max_relevant = AList.lookup (op =) args max_relevantK |> the_default max_relevant_default |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
511 |
val slice = AList.lookup (op =) args sliceK |> the_default slice_default |
45514 | 512 |
val lam_trans = AList.lookup (op =) args lam_transK |
46415 | 513 |
val uncurried_aliases = AList.lookup (op =) args uncurried_aliasesK |
47032 | 514 |
val e_selection_heuristic = AList.lookup (op =) args e_selection_heuristicK |
47049 | 515 |
val term_order = AList.lookup (op =) args term_orderK |
44099 | 516 |
val force_sos = AList.lookup (op =) args force_sosK |
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
|
517 |
|> Option.map (curry (op <>) "false") |
32525 | 518 |
val dir = AList.lookup (op =) args keepK |
32541 | 519 |
val timeout = Mirabelle.get_int_setting args (prover_timeoutK, 30) |
41268 | 520 |
(* always use a hard timeout, but give some slack so that the automatic |
521 |
minimizer has a chance to do its magic *) |
|
46825
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
522 |
val preplay_timeout = AList.lookup (op =) args preplay_timeoutK |
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
523 |
|> the_default preplay_timeout_default |
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
|
524 |
val sh_minimizeLST = available_parameter args sh_minimizeK "minimize" |
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
|
525 |
val max_new_mono_instancesLST = |
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
|
526 |
available_parameter args max_new_mono_instancesK max_new_mono_instancesK |
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
|
527 |
val max_mono_itersLST = available_parameter args max_mono_itersK max_mono_itersK |
41268 | 528 |
val hard_timeout = SOME (2 * timeout) |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
529 |
val (msg, result) = |
46386 | 530 |
run_sh prover_name prover type_enc strict max_relevant slice lam_trans |
47049 | 531 |
uncurried_aliases e_selection_heuristic term_order force_sos |
532 |
hard_timeout timeout preplay_timeout sh_minimizeLST |
|
533 |
max_new_mono_instancesLST max_mono_itersLST dir pos st |
|
32525 | 534 |
in |
32536 | 535 |
case result of |
40062 | 536 |
SH_OK (time_isa, time_prover, names) => |
38700 | 537 |
let |
46340 | 538 |
fun get_thms (name, stature) = |
47154
2c357e2b8436
more robustness in case a theorem cannot be retrieved (which typically happens with backtick facts)
blanchet
parents:
47060
diff
changeset
|
539 |
try (thms_of_name (Proof.context_of st)) name |
2c357e2b8436
more robustness in case a theorem cannot be retrieved (which typically happens with backtick facts)
blanchet
parents:
47060
diff
changeset
|
540 |
|> Option.map (pair (name, stature)) |
32525 | 541 |
in |
32818 | 542 |
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
|
543 |
if trivial then () else change_data id inc_sh_nontriv_success; |
32818 | 544 |
change_data id (inc_sh_lemmas (length names)); |
545 |
change_data id (inc_sh_max_lems (length names)); |
|
546 |
change_data id (inc_sh_time_isa time_isa); |
|
40062 | 547 |
change_data id (inc_sh_time_prover time_prover); |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
548 |
reconstructor := reconstructor_from_msg args msg; |
38826 | 549 |
named_thms := SOME (map_filter get_thms names); |
39340 | 550 |
log (sh_tag id ^ triv_str ^ "succeeded (" ^ string_of_int time_isa ^ "+" ^ |
40062 | 551 |
string_of_int time_prover ^ ") [" ^ prover_name ^ "]:\n" ^ msg) |
32525 | 552 |
end |
40062 | 553 |
| SH_FAIL (time_isa, time_prover) => |
32536 | 554 |
let |
555 |
val _ = change_data id (inc_sh_time_isa time_isa) |
|
40062 | 556 |
val _ = change_data id (inc_sh_time_prover_fail time_prover) |
39340 | 557 |
in log (sh_tag id ^ triv_str ^ "failed: " ^ msg) end |
32536 | 558 |
| SH_ERROR => log (sh_tag id ^ "failed: " ^ msg) |
32525 | 559 |
end |
560 |
||
561 |
end |
|
562 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
563 |
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
|
564 |
({pre=st, log, ...}: Mirabelle.run_args) = |
32525 | 565 |
let |
40069 | 566 |
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
|
567 |
val n0 = length (these (!named_thms)) |
42444
8e5438dc70bb
cleanup: get rid of "may_slice" arguments without changing semantics
blanchet
parents:
42443
diff
changeset
|
568 |
val (prover_name, _) = get_prover ctxt args |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
569 |
val type_enc = AList.lookup (op =) args type_encK |> the_default type_enc_default |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
570 |
val strict = AList.lookup (op =) args strictK |> the_default strict_default |
32525 | 571 |
val timeout = |
572 |
AList.lookup (op =) args minimize_timeoutK |
|
40627
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
wenzelm
parents:
40554
diff
changeset
|
573 |
|> Option.map (fst o read_int o raw_explode) (* FIXME Symbol.explode (?) *) |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
574 |
|> the_default minimize_timeout_default |
46825
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
575 |
val preplay_timeout = AList.lookup (op =) args preplay_timeoutK |
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
576 |
|> the_default preplay_timeout_default |
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
|
577 |
val sh_minimizeLST = available_parameter args sh_minimizeK "minimize" |
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
|
578 |
val max_new_mono_instancesLST = |
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
|
579 |
available_parameter args max_new_mono_instancesK max_new_mono_instancesK |
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
|
580 |
val max_mono_itersLST = available_parameter args max_mono_itersK max_mono_itersK |
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
|
581 |
val params = Sledgehammer_Isar.default_params ctxt |
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
|
582 |
([("provers", prover_name), |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
583 |
("verbose", "true"), |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43569
diff
changeset
|
584 |
("type_enc", type_enc), |
46386 | 585 |
("strict", strict), |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
586 |
("timeout", string_of_int timeout), |
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
|
587 |
("preplay_timeout", preplay_timeout)] |
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
|
588 |
|> sh_minimizeLST (*don't confuse the two minimization flags*) |
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
|
589 |
|> max_new_mono_instancesLST |
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
|
590 |
|> max_mono_itersLST) |
37587 | 591 |
val minimize = |
41742
11e862c68b40
automatically minimize Z3-as-an-ATP proofs (cf. CVC3 and Yices)
blanchet
parents:
41741
diff
changeset
|
592 |
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
|
593 |
true 1 (Sledgehammer_Util.subgoal_count st) |
32525 | 594 |
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
|
595 |
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
|
596 |
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
|
597 |
val msg = message (preplay ()) ^ message_tail |
32525 | 598 |
in |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
599 |
case used_facts of |
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
600 |
SOME named_thms' => |
32609 | 601 |
(change_data id inc_min_succs; |
602 |
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
|
603 |
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
|
604 |
then log (minimize_tag id ^ "already minimal") |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
605 |
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
|
606 |
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
|
607 |
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
|
608 |
) |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
609 |
| NONE => log (minimize_tag id ^ "failed: " ^ msg) |
32525 | 610 |
end |
611 |
||
44542 | 612 |
fun override_params prover type_enc timeout = |
613 |
[("provers", prover), |
|
44449
b622a98b79fb
don't select facts when using sledgehammer_tac for reconstruction
blanchet
parents:
44448
diff
changeset
|
614 |
("max_relevant", "0"), |
44542 | 615 |
("type_enc", type_enc), |
46386 | 616 |
("strict", "true"), |
45706 | 617 |
("slice", "false"), |
44461 | 618 |
("timeout", timeout |> Time.toSeconds |> string_of_int)] |
44430 | 619 |
|
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 |
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
|
621 |
({pre=st, timeout, log, pos, ...}: Mirabelle.run_args) = |
32525 | 622 |
let |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
623 |
fun do_reconstructor named_thms ctxt = |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
624 |
let |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
625 |
val ref_of_str = |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
626 |
suffix ";" #> Outer_Syntax.scan Position.none #> Parse_Spec.xthm |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
627 |
#> fst |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
628 |
val thms = named_thms |> maps snd |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
629 |
val facts = named_thms |> map (ref_of_str o fst o fst) |
48292 | 630 |
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
|
631 |
fun my_timeout time_slice = |
bf8331161ad9
split timeout among ATPs in and add Metis to the mix as backup
blanchet
parents:
44542
diff
changeset
|
632 |
timeout |> Time.toReal |> curry Real.* time_slice |> Time.fromReal |
bf8331161ad9
split timeout among ATPs in and add Metis to the mix as backup
blanchet
parents:
44542
diff
changeset
|
633 |
fun sledge_tac time_slice prover type_enc = |
44542 | 634 |
Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt |
48292 | 635 |
(override_params prover type_enc (my_timeout time_slice)) |
636 |
fact_override |
|
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
637 |
in |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
638 |
if !reconstructor = "sledgehammer_tac" then |
46435 | 639 |
sledge_tac 0.2 ATP_Systems.z3_tptpN "mono_native" |
44768 | 640 |
ORELSE' sledge_tac 0.2 ATP_Systems.eN "mono_guards??" |
641 |
ORELSE' sledge_tac 0.2 ATP_Systems.vampireN "mono_guards??" |
|
642 |
ORELSE' sledge_tac 0.2 ATP_Systems.spassN "poly_tags" |
|
46365 | 643 |
ORELSE' Metis_Tactic.metis_tac [] ATP_Problem_Generate.combsN |
46320 | 644 |
ctxt thms |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
645 |
else if !reconstructor = "smt" then |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
646 |
SMT_Solver.smt_tac ctxt thms |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
647 |
else if full then |
46320 | 648 |
Metis_Tactic.metis_tac [ATP_Proof_Reconstruct.full_typesN] |
649 |
ATP_Proof_Reconstruct.metis_default_lam_trans ctxt thms |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
650 |
else if String.isPrefix "metis (" (!reconstructor) then |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
651 |
let |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
652 |
val (type_encs, lam_trans) = |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
653 |
!reconstructor |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
654 |
|> Outer_Syntax.scan Position.start |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
655 |
|> filter Token.is_proper |> tl |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
656 |
|> Metis_Tactic.parse_metis_options |> fst |
46320 | 657 |
|>> the_default [ATP_Proof_Reconstruct.partial_typesN] |
658 |
||> the_default ATP_Proof_Reconstruct.metis_default_lam_trans |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
659 |
in Metis_Tactic.metis_tac type_encs lam_trans ctxt thms end |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
660 |
else if !reconstructor = "metis" then |
46320 | 661 |
Metis_Tactic.metis_tac [] ATP_Proof_Reconstruct.metis_default_lam_trans ctxt |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
662 |
thms |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
663 |
else |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
664 |
K all_tac |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
665 |
end |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
666 |
fun apply_reconstructor named_thms = |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
667 |
Mirabelle.can_apply timeout (do_reconstructor named_thms) st |
32521 | 668 |
|
669 |
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
|
670 |
| 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
|
671 |
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
|
672 |
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
|
673 |
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
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
else (); |
32521 | 678 |
"succeeded (" ^ string_of_int t ^ ")") |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
679 |
fun timed_reconstructor named_thms = |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
680 |
(with_time (Mirabelle.cpu_time apply_reconstructor named_thms), true) |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
681 |
handle TimeLimit.TimeOut => (change_data id (inc_reconstructor_timeout m); |
34052 | 682 |
("timeout", false)) |
683 |
| ERROR msg => ("error: " ^ msg, false) |
|
32521 | 684 |
|
32525 | 685 |
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
|
686 |
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
|
687 |
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
|
688 |
else change_data id (inc_reconstructor_nontriv_calls m) |
32521 | 689 |
in |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
690 |
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
|
691 |
|> 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
|
692 |
|>> log o prefix (reconstructor_tag reconstructor id) |
34052 | 693 |
|> snd |
32521 | 694 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
695 |
|
41276
285aea0c153c
two layers of timeouts seem to be less reliable than a single layer
blanchet
parents:
41275
diff
changeset
|
696 |
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
|
697 |
|
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
698 |
(* crude hack *) |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
699 |
val num_sledgehammer_calls = Unsynchronized.ref 0 |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
700 |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
then () else |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
705 |
let |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
706 |
val max_calls = |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
707 |
AList.lookup (op =) args max_callsK |> the_default max_calls_default |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
708 |
|> Int.fromString |> the |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
709 |
val _ = num_sledgehammer_calls := !num_sledgehammer_calls + 1; |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
710 |
in |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
711 |
if !num_sledgehammer_calls > max_calls then () |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
712 |
else |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
713 |
let |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
714 |
val reconstructor = Unsynchronized.ref "" |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
715 |
val named_thms = |
46340 | 716 |
Unsynchronized.ref (NONE : ((string * stature) * thm list) list option) |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
717 |
val minimize = AList.defined (op =) args minimizeK |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
718 |
val metis_ft = AList.defined (op =) args metis_ftK |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
719 |
val trivial = |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
720 |
if AList.lookup (op =) args check_trivialK |> the_default trivial_default |
47201 | 721 |
|> Bool.fromString |> the then |
722 |
Try0.try0 (SOME try_timeout) ([], [], [], []) pre |
|
723 |
handle TimeLimit.TimeOut => false |
|
724 |
else false |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
725 |
fun apply_reconstructor m1 m2 = |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
726 |
if metis_ft |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
727 |
then |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
728 |
if not (Mirabelle.catch_result (reconstructor_tag reconstructor) false |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
729 |
(run_reconstructor trivial false m1 name reconstructor |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
730 |
(these (!named_thms))) id st) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
731 |
then |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
732 |
(Mirabelle.catch_result (reconstructor_tag reconstructor) false |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
733 |
(run_reconstructor trivial true m2 name reconstructor |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
734 |
(these (!named_thms))) id st; ()) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
735 |
else () |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
736 |
else |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
737 |
(Mirabelle.catch_result (reconstructor_tag reconstructor) false |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
738 |
(run_reconstructor trivial false m1 name reconstructor |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
739 |
(these (!named_thms))) id st; ()) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
740 |
in |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
741 |
change_data id (set_mini minimize); |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
742 |
Mirabelle.catch sh_tag (run_sledgehammer trivial args reconstructor |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
743 |
named_thms) id st; |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
744 |
if is_some (!named_thms) |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
745 |
then |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
746 |
(apply_reconstructor Unminimized UnminimizedFT; |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
747 |
if minimize andalso not (null (these (!named_thms))) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
748 |
then |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
749 |
(Mirabelle.catch minimize_tag |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
750 |
(run_minimize args reconstructor named_thms) id st; |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
751 |
apply_reconstructor Minimized MinimizedFT) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
752 |
else ()) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
753 |
else () |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
754 |
end |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
755 |
end |
32818 | 756 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
757 |
|
32511 | 758 |
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
|
759 |
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
|
760 |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
761 |
end |