author | blanchet |
Fri, 01 Aug 2014 14:43:57 +0200 | |
changeset 57751 | f453bbc289fa |
parent 57154 | f0eff6393a32 |
child 57752 | 708347f9bfc6 |
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 |
|
55285 | 22 |
val proof_methodK = "proof_method" (*=NAME: how to reconstruct proofs (ie. using metis/smt)*) |
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
|
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 |
|
48293 | 25 |
val max_factsK = "max_facts" (*=NUM: max. relevant clauses to use*) |
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
|
26 |
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
|
27 |
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
|
28 |
val preplay_timeoutK = "preplay_timeout" (*=TIME: timeout for finding reconstructed proof*) |
56411 | 29 |
val isar_proofsK = "isar_proofs" (*: enable Isar proof generation*) |
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
|
30 |
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
|
31 |
|
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 check_trivialK = "check_trivial" (*: check if goals are "trivial" (false by default)*) |
50334 | 33 |
val fact_filterK = "fact_filter" (*=STRING: fact filter*) |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
|
32521 | 45 |
fun sh_tag id = "#" ^ string_of_int id ^ " sledgehammer: " |
32525 | 46 |
fun minimize_tag id = "#" ^ string_of_int id ^ " minimize (sledgehammer): " |
55285 | 47 |
fun proof_method_tag meth id = "#" ^ string_of_int id ^ " " ^ (!meth) ^ " (sledgehammer): " |
32521 | 48 |
|
32525 | 49 |
val separator = "-----" |
50 |
||
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
51 |
(*FIXME sensible to have Mirabelle-level Sledgehammer defaults?*) |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
52 |
(*defaults used in this Mirabelle action*) |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
53 |
val preplay_timeout_default = "1" |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
54 |
val lam_trans_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
55 |
val uncurried_aliases_default = "smart" |
50334 | 56 |
val fact_filter_default = "smart" |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
57 |
val type_enc_default = "smart" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
58 |
val strict_default = "false" |
48293 | 59 |
val max_facts_default = "smart" |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
60 |
val slice_default = "true" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
61 |
val max_calls_default = "10000000" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
62 |
val trivial_default = "false" |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
63 |
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
|
64 |
|
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 |
(*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
|
66 |
(*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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
|
32549 | 73 |
datatype sh_data = ShData of { |
74 |
calls: int, |
|
75 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
76 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
77 |
nontriv_success: int, |
32585 | 78 |
lemmas: int, |
32818 | 79 |
max_lems: int, |
32549 | 80 |
time_isa: int, |
40062 | 81 |
time_prover: int, |
82 |
time_prover_fail: int} |
|
32549 | 83 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
84 |
datatype re_data = ReData of { |
32549 | 85 |
calls: int, |
86 |
success: int, |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
87 |
nontriv_calls: int, |
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
88 |
nontriv_success: int, |
32676 | 89 |
proofs: int, |
32549 | 90 |
time: int, |
32550 | 91 |
timeout: int, |
32990 | 92 |
lemmas: int * int * int, |
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
93 |
posns: (Position.T * bool) list |
32550 | 94 |
} |
32549 | 95 |
|
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
96 |
datatype min_data = MinData of { |
32609 | 97 |
succs: int, |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
98 |
ab_ratios: int |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
99 |
} |
32521 | 100 |
|
32818 | 101 |
fun make_sh_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
102 |
(calls,success,nontriv_calls,nontriv_success,lemmas,max_lems,time_isa, |
40062 | 103 |
time_prover,time_prover_fail) = |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
104 |
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
|
105 |
nontriv_success=nontriv_success, lemmas=lemmas, max_lems=max_lems, |
40062 | 106 |
time_isa=time_isa, time_prover=time_prover, |
107 |
time_prover_fail=time_prover_fail} |
|
32521 | 108 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
109 |
fun make_min_data (succs, ab_ratios) = |
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
110 |
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
|
111 |
|
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 |
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
|
113 |
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
|
114 |
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
|
115 |
nontriv_success=nontriv_success, proofs=proofs, time=time, |
32990 | 116 |
timeout=timeout, lemmas=lemmas, posns=posns} |
32549 | 117 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
|
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
122 |
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
|
123 |
lemmas, max_lems, time_isa, |
40062 | 124 |
time_prover, time_prover_fail}) = (calls, success, nontriv_calls, |
125 |
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
|
126 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
127 |
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
|
128 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
|
55285 | 133 |
datatype proof_method_mode = |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
134 |
Unminimized | Minimized | UnminimizedFT | MinimizedFT |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
135 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
136 |
datatype data = Data of { |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
137 |
sh: sh_data, |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
138 |
min: min_data, |
55285 | 139 |
re_u: re_data, (* proof method with unminimized set of lemmas *) |
140 |
re_m: re_data, (* proof method with minimized set of lemmas *) |
|
141 |
re_uft: re_data, (* proof method with unminimized set of lemmas and fully-typed *) |
|
142 |
re_mft: re_data, (* proof method 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
|
143 |
mini: bool (* with minimization *) |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
144 |
} |
32521 | 145 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
mini=mini} |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
149 |
|
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
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
|
156 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
in make_data (sh, min', re_u, re_m, re_uft, re_mft, mini) end |
32521 | 160 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
161 |
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
|
162 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
163 |
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
|
164 |
| 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
|
165 |
| 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
|
166 |
| map_me g MinimizedFT (u, m, uft, mft) = (u, m, uft, g mft) |
32521 | 167 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
168 |
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
|
169 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
170 |
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
|
171 |
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
|
172 |
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
|
173 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
174 |
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
|
175 |
make_data (sh, min, re_u, re_m, re_uft, re_mft, mini) |
32990 | 176 |
|
177 |
fun inc_max (n:int) (s,sos,m) = (s+n, sos + n*n, Int.max(m,n)); |
|
32521 | 178 |
|
32818 | 179 |
val inc_sh_calls = map_sh_data |
40062 | 180 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
181 |
=> (calls + 1, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail)) |
|
32549 | 182 |
|
32818 | 183 |
val inc_sh_success = map_sh_data |
40062 | 184 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
185 |
=> (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
|
186 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
187 |
val inc_sh_nontriv_calls = map_sh_data |
40062 | 188 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
189 |
=> (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
|
190 |
|
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
191 |
val inc_sh_nontriv_success = map_sh_data |
40062 | 192 |
(fn (calls, success, nontriv_calls, nontriv_success, lemmas,max_lems, time_isa, time_prover, time_prover_fail) |
193 |
=> (calls, success, nontriv_calls, nontriv_success + 1, lemmas,max_lems, time_isa, time_prover, time_prover_fail)) |
|
32585 | 194 |
|
32818 | 195 |
fun inc_sh_lemmas n = map_sh_data |
40062 | 196 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
197 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas+n,max_lems,time_isa,time_prover,time_prover_fail)) |
|
32521 | 198 |
|
32818 | 199 |
fun inc_sh_max_lems n = map_sh_data |
40062 | 200 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
201 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,Int.max(max_lems,n),time_isa,time_prover,time_prover_fail)) |
|
32549 | 202 |
|
32818 | 203 |
fun inc_sh_time_isa t = map_sh_data |
40062 | 204 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
205 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa + t,time_prover,time_prover_fail)) |
|
32818 | 206 |
|
40062 | 207 |
fun inc_sh_time_prover t = map_sh_data |
208 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
209 |
=> (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover + t,time_prover_fail)) |
|
32521 | 210 |
|
40062 | 211 |
fun inc_sh_time_prover_fail t = map_sh_data |
212 |
(fn (calls,success,nontriv_calls, nontriv_success, lemmas,max_lems,time_isa,time_prover,time_prover_fail) |
|
213 |
=> (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
|
214 |
|
32818 | 215 |
val inc_min_succs = map_min_data |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
216 |
(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
|
217 |
|
32818 | 218 |
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
|
219 |
(fn (succs, ab_ratios) => (succs, ab_ratios+r)) |
32549 | 220 |
|
55285 | 221 |
val inc_proof_method_calls = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
222 |
(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
|
223 |
=> (calls + 1, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas,posns)) |
32533 | 224 |
|
55285 | 225 |
val inc_proof_method_success = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
226 |
(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
|
227 |
=> (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
|
228 |
|
55285 | 229 |
val inc_proof_method_nontriv_calls = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
230 |
(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
|
231 |
=> (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
|
232 |
|
55285 | 233 |
val inc_proof_method_nontriv_success = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
234 |
(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
|
235 |
=> (calls, success, nontriv_calls, nontriv_success + 1, proofs, time, timeout, lemmas,posns)) |
32676 | 236 |
|
55285 | 237 |
val inc_proof_method_proofs = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
238 |
(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
|
239 |
=> (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
|
240 |
|
55285 | 241 |
fun inc_proof_method_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
|
242 |
(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
|
243 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time + t, timeout, lemmas,posns)) m |
32536 | 244 |
|
55285 | 245 |
val inc_proof_method_timeout = map_re_data |
39337
ffa577c0bbfa
keep track of trivial vs. nontrivial calls using "try" for 30 seconds
blanchet
parents:
39321
diff
changeset
|
246 |
(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
|
247 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout + 1, lemmas,posns)) |
32549 | 248 |
|
55285 | 249 |
fun inc_proof_method_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
|
250 |
(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
|
251 |
=> (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
|
252 |
|
55285 | 253 |
fun inc_proof_method_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
|
254 |
(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
|
255 |
=> (calls, success, nontriv_calls, nontriv_success, proofs, time, timeout, lemmas, pos::posns)) m |
32521 | 256 |
|
44090 | 257 |
val str0 = string_of_int o the_default 0 |
258 |
||
32521 | 259 |
local |
260 |
||
261 |
val str = string_of_int |
|
262 |
val str3 = Real.fmt (StringCvt.FIX (SOME 3)) |
|
263 |
fun percentage a b = string_of_int (a * 100 div b) |
|
264 |
fun time t = Real.fromInt t / 1000.0 |
|
265 |
fun avg_time t n = |
|
266 |
if n > 0 then (Real.fromInt t / 1000.0) / Real.fromInt n else 0.0 |
|
267 |
||
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
268 |
fun log_sh_data log |
40062 | 269 |
(calls, success, nontriv_calls, nontriv_success, lemmas, max_lems, time_isa, time_prover, time_prover_fail) = |
32818 | 270 |
(log ("Total number of sledgehammer calls: " ^ str calls); |
271 |
log ("Number of successful sledgehammer calls: " ^ str success); |
|
272 |
log ("Number of sledgehammer lemmas: " ^ str lemmas); |
|
273 |
log ("Max number of sledgehammer lemmas: " ^ str max_lems); |
|
274 |
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
|
275 |
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
|
276 |
log ("Number of successful nontrivial sledgehammer calls: " ^ str nontriv_success); |
32818 | 277 |
log ("Total time for sledgehammer calls (Isabelle): " ^ str3 (time time_isa)); |
40062 | 278 |
log ("Total time for successful sledgehammer calls (ATP): " ^ str3 (time time_prover)); |
279 |
log ("Total time for failed sledgehammer calls (ATP): " ^ str3 (time time_prover_fail)); |
|
32536 | 280 |
log ("Average time for sledgehammer calls (Isabelle): " ^ |
32818 | 281 |
str3 (avg_time time_isa calls)); |
32533 | 282 |
log ("Average time for successful sledgehammer calls (ATP): " ^ |
40062 | 283 |
str3 (avg_time time_prover success)); |
32536 | 284 |
log ("Average time for failed sledgehammer calls (ATP): " ^ |
40062 | 285 |
str3 (avg_time time_prover_fail (calls - success))) |
32533 | 286 |
) |
32521 | 287 |
|
39341
d2b981a0429a
indicate triviality in the list of proved things
blanchet
parents:
39340
diff
changeset
|
288 |
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
|
289 |
str0 (Position.line_of pos) ^ ":" ^ str0 (Position.offset_of pos) ^ |
44090 | 290 |
(if triv then "[T]" else "") |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
291 |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
292 |
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
|
293 |
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
|
294 |
(lemmas, lems_sos, lems_max), re_posns) = |
55285 | 295 |
(log ("Total number of " ^ tag ^ "proof method calls: " ^ str re_calls); |
296 |
log ("Number of successful " ^ tag ^ "proof method calls: " ^ str re_success ^ |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
297 |
" (proof: " ^ str re_proofs ^ ")"); |
55285 | 298 |
log ("Number of " ^ tag ^ "proof method timeouts: " ^ str re_timeout); |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
299 |
log ("Success rate: " ^ percentage re_success sh_calls ^ "%"); |
55285 | 300 |
log ("Total number of nontrivial " ^ tag ^ "proof method calls: " ^ str re_nontriv_calls); |
301 |
log ("Number of successful nontrivial " ^ tag ^ "proof method calls: " ^ str re_nontriv_success ^ |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
302 |
" (proof: " ^ str re_proofs ^ ")"); |
55285 | 303 |
log ("Number of successful " ^ tag ^ "proof method lemmas: " ^ str lemmas); |
304 |
log ("SOS of successful " ^ tag ^ "proof method lemmas: " ^ str lems_sos); |
|
305 |
log ("Max number of successful " ^ tag ^ "proof method lemmas: " ^ str lems_max); |
|
306 |
log ("Total time for successful " ^ tag ^ "proof method calls: " ^ str3 (time re_time)); |
|
307 |
log ("Average time for successful " ^ tag ^ "proof method calls: " ^ |
|
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
308 |
str3 (avg_time re_time re_success)); |
32551
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
else () |
421323205efd
position information is now passed to all actions;
nipkow
parents:
32550
diff
changeset
|
312 |
) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
313 |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35830
diff
changeset
|
314 |
fun log_min_data log (succs, ab_ratios) = |
32609 | 315 |
(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
|
316 |
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
|
317 |
) |
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
318 |
|
32521 | 319 |
in |
320 |
||
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
321 |
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
|
322 |
let |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
323 |
val ShData {calls=sh_calls, ...} = sh |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
324 |
|
40667
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 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
|
326 |
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
|
327 |
log_re_data log tag sh_calls (tuple_of_re_data m) |
55285 | 328 |
fun log_proof_method (tag1, m1) (tag2, m2) = app_if m1 (fn () => |
40667
b8579f24ce67
make Mirabelle take into consideration whether the SMT solver proof should be reconstructed with Metis or SMT
blanchet
parents:
40627
diff
changeset
|
329 |
(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
|
330 |
in |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
331 |
if sh_calls > 0 |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
332 |
then |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
333 |
(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
|
334 |
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
|
335 |
log ""; |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
336 |
if not mini |
55285 | 337 |
then log_proof_method ("", re_u) ("fully-typed ", re_uft) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
338 |
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
|
339 |
app_if re_u (fn () => |
55285 | 340 |
(log_proof_method ("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
|
341 |
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
|
342 |
app_if re_m (fn () => |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
343 |
(log_min_data log (tuple_of_min_data min); log ""; |
55285 | 344 |
log_proof_method ("", re_m) ("fully-typed ", re_mft)))))) |
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
345 |
else () |
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
346 |
end |
32521 | 347 |
|
348 |
end |
|
349 |
||
55211 | 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 |
|
55205 | 361 |
fun get_prover_name thy args = |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
362 |
let |
40062 | 363 |
fun default_prover_name () = |
55205 | 364 |
hd (#provers (Sledgehammer_Commands.default_params thy [])) |
47060
e2741ec9ae36
prefer explicitly qualified exception List.Empty;
wenzelm
parents:
47049
diff
changeset
|
365 |
handle List.Empty => error "No ATP available." |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
366 |
in |
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
367 |
(case AList.lookup (op =) args proverK of |
50352 | 368 |
SOME name => name |
369 |
| NONE => default_prover_name ()) |
|
370 |
end |
|
371 |
||
372 |
fun get_prover ctxt name params goal all_facts = |
|
373 |
let |
|
54503 | 374 |
val learn = Sledgehammer_MaSh.mash_learn_proof ctxt params (prop_of goal) all_facts |
50352 | 375 |
in |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
376 |
Sledgehammer_Prover_Minimize.get_minimizing_prover ctxt Sledgehammer_Prover.Normal learn name |
33016
b73b74fe23c3
proper exceptions instead of unhandled partiality
boehmes
parents:
32991
diff
changeset
|
377 |
end |
32525 | 378 |
|
46340 | 379 |
type stature = ATP_Problem_Generate.stature |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38700
diff
changeset
|
380 |
|
53081
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
381 |
fun good_line s = |
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
382 |
(String.isSubstring " ms)" s orelse String.isSubstring " s)" s) |
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
383 |
andalso not (String.isSubstring "(> " s) |
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
384 |
andalso not (String.isSubstring ", > " s) |
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
385 |
andalso not (String.isSubstring "may fail" s) |
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
386 |
|
51206 | 387 |
(* Fragile hack *) |
55285 | 388 |
fun proof_method_from_msg args msg = |
389 |
(case AList.lookup (op =) args proof_methodK of |
|
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
390 |
SOME name => name |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41338
diff
changeset
|
391 |
| NONE => |
53081
2a62d848a56a
improved ad hoc success detection in Mirabelle -- if the metis call fails and the structured proof succeeds, remember only the success
blanchet
parents:
52555
diff
changeset
|
392 |
if exists good_line (split_lines msg) then |
51203 | 393 |
"none" (* trust the preplayed proof *) |
394 |
else if String.isSubstring "metis (" msg then |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
395 |
msg |> Substring.full |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
396 |
|> Substring.position "metis (" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
397 |
|> snd |> Substring.position ")" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
398 |
|> fst |> Substring.string |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
399 |
|> suffix ")" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
400 |
else if String.isSubstring "metis" msg then |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
401 |
"metis" |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
402 |
else |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
403 |
"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
|
404 |
|
32521 | 405 |
local |
406 |
||
32536 | 407 |
datatype sh_result = |
46340 | 408 |
SH_OK of int * int * (string * stature) list | |
32536 | 409 |
SH_FAIL of int * int | |
410 |
SH_ERROR |
|
411 |
||
50352 | 412 |
fun run_sh prover_name fact_filter type_enc strict max_facts slice |
50334 | 413 |
lam_trans uncurried_aliases e_selection_heuristic term_order force_sos |
56411 | 414 |
hard_timeout timeout preplay_timeout isar_proofsLST sh_minimizeLST |
50334 | 415 |
max_new_mono_instancesLST max_mono_itersLST dir pos st = |
32521 | 416 |
let |
55205 | 417 |
val thy = Proof.theory_of st |
38998 | 418 |
val {context = ctxt, facts = chained_ths, goal} = Proof.goal st |
419 |
val i = 1 |
|
44090 | 420 |
fun set_file_name (SOME dir) = |
55212 | 421 |
Config.put Sledgehammer_Prover_ATP.atp_dest_dir dir |
422 |
#> Config.put Sledgehammer_Prover_ATP.atp_problem_prefix |
|
44424 | 423 |
("prob_" ^ str0 (Position.line_of pos) ^ "__") |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
424 |
#> Config.put SMT2_Config.debug_files |
56811 | 425 |
(dir ^ "/" ^ Name.desymbolize (SOME false) (ATP_Util.timestamp ()) ^ "_" |
41338 | 426 |
^ serial_string ()) |
44090 | 427 |
| set_file_name NONE = I |
39321 | 428 |
val st' = |
47030 | 429 |
st |
430 |
|> Proof.map_context |
|
431 |
(set_file_name dir |
|
47032 | 432 |
#> (Option.map (Config.put ATP_Systems.e_selection_heuristic) |
433 |
e_selection_heuristic |> the_default I) |
|
47049 | 434 |
#> (Option.map (Config.put ATP_Systems.term_order) |
435 |
term_order |> the_default I) |
|
47030 | 436 |
#> (Option.map (Config.put ATP_Systems.force_sos) |
437 |
force_sos |> the_default I)) |
|
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
438 |
val params as {max_facts, preplay_timeout, ...} = |
55205 | 439 |
Sledgehammer_Commands.default_params thy |
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
|
440 |
([("verbose", "true"), |
50334 | 441 |
("fact_filter", fact_filter), |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43569
diff
changeset
|
442 |
("type_enc", type_enc), |
46386 | 443 |
("strict", strict), |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
444 |
("lam_trans", lam_trans |> the_default lam_trans_default), |
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
445 |
("uncurried_aliases", uncurried_aliases |> the_default uncurried_aliases_default), |
48293 | 446 |
("max_facts", max_facts), |
45706 | 447 |
("slice", slice), |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
448 |
("timeout", string_of_int timeout), |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
449 |
("preplay_timeout", preplay_timeout)] |
56411 | 450 |
|> isar_proofsLST |
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
|
451 |
|> 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
|
452 |
|> 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
|
453 |
|> max_mono_itersLST) |
55205 | 454 |
val default_max_facts = |
455 |
Sledgehammer_Prover_Minimize.default_max_facts_of_prover ctxt prover_name |
|
52196
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52125
diff
changeset
|
456 |
val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal goal i ctxt |
32574
719426c9e1eb
added hard timeout for sledgehammer based on elapsed time (no need to trust ATP's timeout handling);
boehmes
parents:
32571
diff
changeset
|
457 |
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
|
458 |
(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
|
459 |
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
|
460 |
| SOME secs => TimeLimit.timeLimit (Time.fromSeconds secs)) |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
461 |
fun failed failure = |
51009
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51008
diff
changeset
|
462 |
({outcome = SOME failure, used_facts = [], used_from = [], |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
463 |
preferred_methss = (Sledgehammer_Proof_Methods.Auto_Method, []), run_time = Time.zeroTime, |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
464 |
message = K ""}, ~1) |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
465 |
val ({outcome, used_facts, preferred_methss, run_time, message, ...} |
55201 | 466 |
: Sledgehammer_Prover.prover_result, |
51009
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51008
diff
changeset
|
467 |
time_isa) = time_limit (Mirabelle.cpu_time (fn () => |
41275 | 468 |
let |
55212 | 469 |
val ho_atp = Sledgehammer_Prover_ATP.is_ho_atp ctxt prover_name |
48299 | 470 |
val reserved = Sledgehammer_Util.reserved_isar_keyword_table () |
471 |
val css_table = Sledgehammer_Fact.clasimpset_rule_table_of ctxt |
|
41275 | 472 |
val facts = |
48288
255c6e1fd505
rationalize relevance filter, slowing moving code from Iter to MaSh
blanchet
parents:
48250
diff
changeset
|
473 |
Sledgehammer_Fact.nearly_all_facts ctxt ho_atp |
48299 | 474 |
Sledgehammer_Fact.no_fact_override reserved css_table chained_ths |
475 |
hyp_ts concl_t |
|
51010 | 476 |
val factss = |
51007
4f694d52bf62
thread fact triple (MeSh, MePo, MaSh) to allow different filters in different slices
blanchet
parents:
51005
diff
changeset
|
477 |
facts |
48381 | 478 |
|> Sledgehammer_MaSh.relevant_facts ctxt params prover_name |
48293 | 479 |
(the_default default_max_facts max_facts) |
48292 | 480 |
Sledgehammer_Fact.no_fact_override hyp_ts concl_t |
51010 | 481 |
|> tap (fn factss => |
50868 | 482 |
"Line " ^ str0 (Position.line_of pos) ^ ": " ^ |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
483 |
Sledgehammer.string_of_factss factss |
50867 | 484 |
|> Output.urgent_message) |
50352 | 485 |
val prover = get_prover ctxt prover_name params goal facts |
41275 | 486 |
val problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54130
diff
changeset
|
487 |
{comment = "", state = st', goal = goal, subgoal = i, |
51010 | 488 |
subgoal_count = Sledgehammer_Util.subgoal_count st, factss = factss} |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
489 |
in prover params problem end)) () |
42953
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
490 |
handle TimeLimit.TimeOut => failed ATP_Proof.TimedOut |
26111aafab12
detect inappropriate problems and crashes better in Waldmeister
blanchet
parents:
42952
diff
changeset
|
491 |
| Fail "inappropriate" => failed ATP_Proof.Inappropriate |
45371 | 492 |
val time_prover = run_time |> Time.toMilliseconds |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
493 |
val msg = message (fn () => Sledgehammer.play_one_line_proof preplay_timeout used_facts st' i |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
494 |
preferred_methss) |
32521 | 495 |
in |
55211 | 496 |
(case outcome of |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
497 |
NONE => (msg, SH_OK (time_isa, time_prover, used_facts)) |
55211 | 498 |
| SOME _ => (msg, SH_FAIL (time_isa, time_prover))) |
32521 | 499 |
end |
37994
b04307085a09
make TPTP generator accept full first-order formulas
blanchet
parents:
37631
diff
changeset
|
500 |
handle ERROR msg => ("error: " ^ msg, SH_ERROR) |
32521 | 501 |
|
32498
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
502 |
in |
1132c7c13f36
Mirabelle: actions are responsible for handling exceptions,
boehmes
parents:
32496
diff
changeset
|
503 |
|
55285 | 504 |
fun run_sledgehammer trivial args proof_method named_thms id |
44090 | 505 |
({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
|
506 |
let |
55205 | 507 |
val thy = Proof.theory_of st |
39340 | 508 |
val triv_str = if trivial then "[T] " else "" |
32536 | 509 |
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
|
510 |
val _ = if trivial then () else change_data id inc_sh_nontriv_calls |
55205 | 511 |
val prover_name = get_prover_name thy args |
50334 | 512 |
val fact_filter = AList.lookup (op =) args fact_filterK |> the_default fact_filter_default |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
513 |
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
|
514 |
val strict = AList.lookup (op =) args strictK |> the_default strict_default |
48293 | 515 |
val max_facts = |
55211 | 516 |
(case AList.lookup (op =) args max_factsK of |
48293 | 517 |
SOME max => max |
55211 | 518 |
| NONE => |
519 |
(case AList.lookup (op =) args max_relevantK of |
|
520 |
SOME max => max |
|
521 |
| NONE => max_facts_default)) |
|
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
522 |
val slice = AList.lookup (op =) args sliceK |> the_default slice_default |
45514 | 523 |
val lam_trans = AList.lookup (op =) args lam_transK |
46415 | 524 |
val uncurried_aliases = AList.lookup (op =) args uncurried_aliasesK |
47032 | 525 |
val e_selection_heuristic = AList.lookup (op =) args e_selection_heuristicK |
47049 | 526 |
val term_order = AList.lookup (op =) args term_orderK |
44099 | 527 |
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
|
528 |
|> Option.map (curry (op <>) "false") |
32525 | 529 |
val dir = AList.lookup (op =) args keepK |
32541 | 530 |
val timeout = Mirabelle.get_int_setting args (prover_timeoutK, 30) |
41268 | 531 |
(* always use a hard timeout, but give some slack so that the automatic |
532 |
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
|
533 |
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
|
534 |
|> the_default preplay_timeout_default |
56411 | 535 |
val isar_proofsLST = available_parameter args isar_proofsK "isar_proofs" |
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
|
536 |
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
|
537 |
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
|
538 |
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
|
539 |
val max_mono_itersLST = available_parameter args max_mono_itersK max_mono_itersK |
48702
e1752ccccc34
increase defensive timeout that should typically not kick in thanks to solid time limits in Sledgehammer (otherwise, Mirabelle-based evaluations might be distorted)
boehmes
parents:
48558
diff
changeset
|
540 |
val hard_timeout = SOME (4 * timeout) |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
541 |
val (msg, result) = |
50352 | 542 |
run_sh prover_name fact_filter type_enc strict max_facts slice lam_trans |
543 |
uncurried_aliases e_selection_heuristic term_order force_sos |
|
56411 | 544 |
hard_timeout timeout preplay_timeout isar_proofsLST sh_minimizeLST |
47049 | 545 |
max_new_mono_instancesLST max_mono_itersLST dir pos st |
32525 | 546 |
in |
55211 | 547 |
(case result of |
40062 | 548 |
SH_OK (time_isa, time_prover, names) => |
38700 | 549 |
let |
46340 | 550 |
fun get_thms (name, stature) = |
50267
1da2e67242d6
moved thms_of_name to Sledgehammer_Util and removed copies, updated references
smolkas
parents:
49916
diff
changeset
|
551 |
try (Sledgehammer_Util.thms_of_name (Proof.context_of st)) |
49916
412346127bfa
fixed theorem lookup code in Isar proof reconstruction
blanchet
parents:
49914
diff
changeset
|
552 |
name |
47154
2c357e2b8436
more robustness in case a theorem cannot be retrieved (which typically happens with backtick facts)
blanchet
parents:
47060
diff
changeset
|
553 |
|> Option.map (pair (name, stature)) |
32525 | 554 |
in |
32818 | 555 |
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
|
556 |
if trivial then () else change_data id inc_sh_nontriv_success; |
32818 | 557 |
change_data id (inc_sh_lemmas (length names)); |
558 |
change_data id (inc_sh_max_lems (length names)); |
|
559 |
change_data id (inc_sh_time_isa time_isa); |
|
40062 | 560 |
change_data id (inc_sh_time_prover time_prover); |
55285 | 561 |
proof_method := proof_method_from_msg args msg; |
38826 | 562 |
named_thms := SOME (map_filter get_thms names); |
39340 | 563 |
log (sh_tag id ^ triv_str ^ "succeeded (" ^ string_of_int time_isa ^ "+" ^ |
40062 | 564 |
string_of_int time_prover ^ ") [" ^ prover_name ^ "]:\n" ^ msg) |
32525 | 565 |
end |
40062 | 566 |
| SH_FAIL (time_isa, time_prover) => |
32536 | 567 |
let |
568 |
val _ = change_data id (inc_sh_time_isa time_isa) |
|
40062 | 569 |
val _ = change_data id (inc_sh_time_prover_fail time_prover) |
39340 | 570 |
in log (sh_tag id ^ triv_str ^ "failed: " ^ msg) end |
55211 | 571 |
| SH_ERROR => log (sh_tag id ^ "failed: " ^ msg)) |
32525 | 572 |
end |
573 |
||
574 |
end |
|
575 |
||
55285 | 576 |
fun run_minimize args meth named_thms id ({pre = st, log, ...} : Mirabelle.run_args) = |
32525 | 577 |
let |
55205 | 578 |
val thy = Proof.theory_of st |
54130
b4e6cd4cab92
thread the goal through instead of relying on unreliable (possibly fake) state
blanchet
parents:
54128
diff
changeset
|
579 |
val {goal, ...} = Proof.goal st |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
580 |
val i = 1 |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
581 |
val preferred_methss = |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
582 |
(Sledgehammer_Proof_Methods.Auto_Method, [[Sledgehammer_Proof_Methods.Auto_Method]]) (* wrong *) |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32567
diff
changeset
|
583 |
val n0 = length (these (!named_thms)) |
55205 | 584 |
val prover_name = get_prover_name thy args |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
585 |
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
|
586 |
val strict = AList.lookup (op =) args strictK |> the_default strict_default |
32525 | 587 |
val timeout = |
588 |
AList.lookup (op =) args minimize_timeoutK |
|
40627
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
wenzelm
parents:
40554
diff
changeset
|
589 |
|> 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
|
590 |
|> the_default minimize_timeout_default |
46825
98300d5f9cc0
added sh_minimize and preplay_timeout options to Mirabelle's Sledgehammer action;
sultana
parents:
46641
diff
changeset
|
591 |
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
|
592 |
|> the_default preplay_timeout_default |
56411 | 593 |
val isar_proofsLST = available_parameter args isar_proofsK "isar_proofs" |
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
|
594 |
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
|
595 |
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
|
596 |
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
|
597 |
val max_mono_itersLST = available_parameter args max_mono_itersK max_mono_itersK |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
598 |
val params as {preplay_timeout, ...} = Sledgehammer_Commands.default_params thy |
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
|
599 |
([("provers", prover_name), |
41155
85da8cbb4966
added support for "type_sys" option to Mirabelle
blanchet
parents:
41154
diff
changeset
|
600 |
("verbose", "true"), |
43626
a867ebb12209
renamed "type_sys" to "type_enc", which is more accurate
blanchet
parents:
43569
diff
changeset
|
601 |
("type_enc", type_enc), |
46386 | 602 |
("strict", strict), |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
603 |
("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
|
604 |
("preplay_timeout", preplay_timeout)] |
56411 | 605 |
|> isar_proofsLST |
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
|
606 |
|> 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
|
607 |
|> 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
|
608 |
|> max_mono_itersLST) |
37587 | 609 |
val minimize = |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
610 |
Sledgehammer_Prover_Minimize.minimize_facts (K ()) prover_name params true 1 |
54503 | 611 |
(Sledgehammer_Util.subgoal_count st) |
32525 | 612 |
val _ = log separator |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
613 |
val (used_facts, message) = minimize st goal (these (!named_thms)) |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
614 |
val msg = message (fn () => Sledgehammer.play_one_line_proof preplay_timeout |
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
615 |
(map fst (these used_facts)) st i preferred_methss) |
32525 | 616 |
in |
55211 | 617 |
(case used_facts of |
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
618 |
SOME named_thms' => |
32609 | 619 |
(change_data id inc_min_succs; |
620 |
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
|
621 |
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
|
622 |
then log (minimize_tag id ^ "already minimal") |
55285 | 623 |
else (meth := proof_method_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
|
624 |
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
|
625 |
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
|
626 |
) |
55211 | 627 |
| NONE => log (minimize_tag id ^ "failed: " ^ msg)) |
32525 | 628 |
end |
629 |
||
44542 | 630 |
fun override_params prover type_enc timeout = |
631 |
[("provers", prover), |
|
48293 | 632 |
("max_facts", "0"), |
44542 | 633 |
("type_enc", type_enc), |
46386 | 634 |
("strict", "true"), |
45706 | 635 |
("slice", "false"), |
44461 | 636 |
("timeout", timeout |> Time.toSeconds |> string_of_int)] |
44430 | 637 |
|
55285 | 638 |
fun run_proof_method trivial full m name meth named_thms id |
32567
de411627a985
explicitly export type abbreviations (as usual in SML97);
wenzelm
parents:
32564
diff
changeset
|
639 |
({pre=st, timeout, log, pos, ...}: Mirabelle.run_args) = |
32525 | 640 |
let |
55285 | 641 |
fun do_method named_thms ctxt = |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
642 |
let |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
643 |
val ref_of_str = |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
644 |
suffix ";" #> Outer_Syntax.scan Position.none #> Parse_Spec.xthm |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
645 |
#> fst |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
646 |
val thms = named_thms |> maps snd |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
647 |
val facts = named_thms |> map (ref_of_str o fst o fst) |
48292 | 648 |
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
|
649 |
fun my_timeout time_slice = |
bf8331161ad9
split timeout among ATPs in and add Metis to the mix as backup
blanchet
parents:
44542
diff
changeset
|
650 |
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
|
651 |
fun sledge_tac time_slice prover type_enc = |
44542 | 652 |
Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt |
55211 | 653 |
(override_params prover type_enc (my_timeout time_slice)) fact_override |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
654 |
in |
55285 | 655 |
if !meth = "sledgehammer_tac" then |
57154 | 656 |
sledge_tac 0.2 ATP_Proof.vampireN "mono_native" |
657 |
ORELSE' sledge_tac 0.2 ATP_Proof.eN "poly_guards??" |
|
658 |
ORELSE' sledge_tac 0.2 ATP_Proof.spassN "mono_native" |
|
659 |
ORELSE' sledge_tac 0.2 ATP_Proof.z3_tptpN "poly_tags??" |
|
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
660 |
ORELSE' SMT2_Solver.smt2_tac ctxt thms |
55285 | 661 |
else if !meth = "smt" then |
57751
f453bbc289fa
modernized Mirabelle (a bit) and made it compile
blanchet
parents:
57154
diff
changeset
|
662 |
SMT2_Solver.smt2_tac ctxt thms |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
663 |
else if full then |
46320 | 664 |
Metis_Tactic.metis_tac [ATP_Proof_Reconstruct.full_typesN] |
54500 | 665 |
ATP_Proof_Reconstruct.default_metis_lam_trans ctxt thms |
55285 | 666 |
else if String.isPrefix "metis (" (!meth) then |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
667 |
let |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
668 |
val (type_encs, lam_trans) = |
55285 | 669 |
!meth |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
670 |
|> Outer_Syntax.scan Position.start |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
671 |
|> filter Token.is_proper |> tl |
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
672 |
|> Metis_Tactic.parse_metis_options |> fst |
46320 | 673 |
|>> the_default [ATP_Proof_Reconstruct.partial_typesN] |
54500 | 674 |
||> the_default ATP_Proof_Reconstruct.default_metis_lam_trans |
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
675 |
in Metis_Tactic.metis_tac type_encs lam_trans ctxt thms end |
55285 | 676 |
else if !meth = "metis" then |
55211 | 677 |
Metis_Tactic.metis_tac [] ATP_Proof_Reconstruct.default_metis_lam_trans ctxt thms |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
678 |
else |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
679 |
K all_tac |
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
680 |
end |
55285 | 681 |
fun apply_method named_thms = |
682 |
Mirabelle.can_apply timeout (do_method named_thms) st |
|
32521 | 683 |
|
684 |
fun with_time (false, t) = "failed (" ^ string_of_int t ^ ")" |
|
55285 | 685 |
| with_time (true, t) = (change_data id (inc_proof_method_success m); |
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 |
if trivial then () |
55285 | 687 |
else change_data id (inc_proof_method_nontriv_success m); |
688 |
change_data id (inc_proof_method_lemmas m (length named_thms)); |
|
689 |
change_data id (inc_proof_method_time m t); |
|
690 |
change_data id (inc_proof_method_posns m (pos, trivial)); |
|
691 |
if name = "proof" then change_data id (inc_proof_method_proofs m) else (); |
|
32521 | 692 |
"succeeded (" ^ string_of_int t ^ ")") |
55285 | 693 |
fun timed_method named_thms = |
694 |
(with_time (Mirabelle.cpu_time apply_method named_thms), true) |
|
695 |
handle TimeLimit.TimeOut => (change_data id (inc_proof_method_timeout m); ("timeout", false)) |
|
34052 | 696 |
| ERROR msg => ("error: " ^ msg, false) |
32521 | 697 |
|
32525 | 698 |
val _ = log separator |
55285 | 699 |
val _ = change_data id (inc_proof_method_calls m) |
700 |
val _ = if trivial then () else change_data id (inc_proof_method_nontriv_calls m) |
|
32521 | 701 |
in |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44461
diff
changeset
|
702 |
named_thms |
55285 | 703 |
|> timed_method |
704 |
|>> log o prefix (proof_method_tag meth id) |
|
34052 | 705 |
|> snd |
32521 | 706 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
707 |
|
41276
285aea0c153c
two layers of timeouts seem to be less reliable than a single layer
blanchet
parents:
41275
diff
changeset
|
708 |
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
|
709 |
|
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
710 |
(* crude hack *) |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
711 |
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
|
712 |
|
34035
08d34921b7dd
also consider the fully-typed version of metis for Mirabelle measurements
boehmes
parents:
33316
diff
changeset
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
then () else |
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
717 |
let |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
718 |
val max_calls = |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
719 |
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
|
720 |
|> Int.fromString |> the |
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
721 |
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
|
722 |
in |
44431
3e0ce0ae1022
added "max_calls" option to get a fixed number of Sledgehammer calls per theory
blanchet
parents:
44430
diff
changeset
|
723 |
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
|
724 |
else |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
725 |
let |
55285 | 726 |
val meth = Unsynchronized.ref "" |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
727 |
val named_thms = |
46340 | 728 |
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
|
729 |
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
|
730 |
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
|
731 |
val trivial = |
47481
b5873d4ff1e2
gathered mirabelle_sledgehammer's hardcoded defaults
sultana
parents:
47480
diff
changeset
|
732 |
if AList.lookup (op =) args check_trivialK |> the_default trivial_default |
51951
fab4ab92e812
more standard Isabelle/ML operations -- avoid inaccurate Bool.fromString;
wenzelm
parents:
51210
diff
changeset
|
733 |
|> Markup.parse_bool then |
47201 | 734 |
Try0.try0 (SOME try_timeout) ([], [], [], []) pre |
735 |
handle TimeLimit.TimeOut => false |
|
736 |
else false |
|
55285 | 737 |
fun apply_method m1 m2 = |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
738 |
if metis_ft |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
739 |
then |
55285 | 740 |
if not (Mirabelle.catch_result (proof_method_tag meth) false |
741 |
(run_proof_method trivial false m1 name meth (these (!named_thms))) id st) |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
742 |
then |
55285 | 743 |
(Mirabelle.catch_result (proof_method_tag meth) false |
744 |
(run_proof_method trivial true m2 name meth (these (!named_thms))) id st; ()) |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
745 |
else () |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
746 |
else |
55285 | 747 |
(Mirabelle.catch_result (proof_method_tag meth) false |
748 |
(run_proof_method trivial false m1 name meth (these (!named_thms))) id st; ()) |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
749 |
in |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
750 |
change_data id (set_mini minimize); |
55285 | 751 |
Mirabelle.catch sh_tag (run_sledgehammer trivial args meth named_thms) id st; |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
752 |
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
|
753 |
then |
55285 | 754 |
(apply_method Unminimized UnminimizedFT; |
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
755 |
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
|
756 |
then |
55285 | 757 |
(Mirabelle.catch minimize_tag (run_minimize args meth named_thms) id st; |
758 |
apply_method Minimized MinimizedFT) |
|
44448
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
759 |
else ()) |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
760 |
else () |
04bd6a9307c6
don't perform a triviality check if the goal is skipped anyway
blanchet
parents:
44447
diff
changeset
|
761 |
end |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
34052
diff
changeset
|
762 |
end |
32818 | 763 |
end |
32385
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
764 |
|
32511 | 765 |
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
|
766 |
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
|
767 |
|
594890623c46
split actions from Mirabelle core (Mirabelle may thus be applied to basic theories in HOL)
boehmes
parents:
diff
changeset
|
768 |
end |