author | blanchet |
Fri, 17 Dec 2010 18:23:56 +0100 | |
changeset 41255 | a80024d7b71b |
parent 41242 | 8edeb1dbbc76 |
child 41259 | 13972ced98d9 |
permissions | -rw-r--r-- |
38988 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_minimize.ML |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
2 |
Author: Philipp Meyer, TU Muenchen |
36370
a4f601daa175
centralized ATP-specific error handling in "atp_wrapper.ML"
blanchet
parents:
36369
diff
changeset
|
3 |
Author: Jasmin Blanchette, TU Muenchen |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
4 |
|
40977 | 5 |
Minimization of fact list for Metis using external provers. |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
6 |
*) |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
7 |
|
38988 | 8 |
signature SLEDGEHAMMER_MINIMIZE = |
32525 | 9 |
sig |
38988 | 10 |
type locality = Sledgehammer_Filter.locality |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
11 |
type params = Sledgehammer_Provers.params |
35867 | 12 |
|
41255
a80024d7b71b
added debugging option to find out how good the relevance filter was at identifying relevant facts
blanchet
parents:
41242
diff
changeset
|
13 |
val filter_used_facts : ''a list -> (''a * 'b) list -> (''a * 'b) list |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
14 |
val minimize_facts : |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
15 |
params -> bool -> int -> int -> Proof.state |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
16 |
-> ((string * locality) * thm list) list |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38745
diff
changeset
|
17 |
-> ((string * locality) * thm list) list option * string |
38996 | 18 |
val run_minimize : |
19 |
params -> int -> (Facts.ref * Attrib.src list) list -> Proof.state -> unit |
|
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35865
diff
changeset
|
20 |
end; |
32525 | 21 |
|
38988 | 22 |
structure Sledgehammer_Minimize : SLEDGEHAMMER_MINIMIZE = |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
23 |
struct |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
24 |
|
39496
a52a4e4399c1
got caught once again by SML's pattern maching (ctor vs. var)
blanchet
parents:
39491
diff
changeset
|
25 |
open ATP_Proof |
36142
f5e15e9aae10
make Sledgehammer "minimize" output less confusing + round up (not down) time limits to nearest second
blanchet
parents:
36063
diff
changeset
|
26 |
open Sledgehammer_Util |
38988 | 27 |
open Sledgehammer_Filter |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
28 |
open Sledgehammer_Provers |
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35865
diff
changeset
|
29 |
|
36370
a4f601daa175
centralized ATP-specific error handling in "atp_wrapper.ML"
blanchet
parents:
36369
diff
changeset
|
30 |
(* wrapper for calling external prover *) |
31236 | 31 |
|
40553
1264c9172338
pick up SMT solver crashes and report them to the user/Mirabelle if desired
blanchet
parents:
40342
diff
changeset
|
32 |
fun string_for_failure ATP_Proof.Unprovable = "Unprovable." |
1264c9172338
pick up SMT solver crashes and report them to the user/Mirabelle if desired
blanchet
parents:
40342
diff
changeset
|
33 |
| string_for_failure ATP_Proof.TimedOut = "Timed out." |
1264c9172338
pick up SMT solver crashes and report them to the user/Mirabelle if desired
blanchet
parents:
40342
diff
changeset
|
34 |
| string_for_failure ATP_Proof.Interrupted = "Interrupted." |
1264c9172338
pick up SMT solver crashes and report them to the user/Mirabelle if desired
blanchet
parents:
40342
diff
changeset
|
35 |
| string_for_failure _ = "Error." |
31236 | 36 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
37 |
fun n_facts names = |
38698
d19c3a7ce38b
clean handling of whether a fact is chained or not;
blanchet
parents:
38696
diff
changeset
|
38 |
let val n = length names in |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
39 |
string_of_int n ^ " fact" ^ plural_s n ^ |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
40 |
(if n > 0 then |
38698
d19c3a7ce38b
clean handling of whether a fact is chained or not;
blanchet
parents:
38696
diff
changeset
|
41 |
": " ^ (names |> map fst |
d19c3a7ce38b
clean handling of whether a fact is chained or not;
blanchet
parents:
38696
diff
changeset
|
42 |
|> sort_distinct string_ord |> space_implode " ") |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
43 |
else |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
44 |
"") |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
45 |
end |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
46 |
|
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
47 |
fun print silent f = if silent then () else Output.urgent_message (f ()) |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
48 |
|
41138
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41134
diff
changeset
|
49 |
fun test_facts ({debug, overlord, provers, type_sys, isar_proof, |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
50 |
isar_shrink_factor, ...} : params) silent (prover : prover) |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
51 |
explicit_apply timeout i n state facts = |
31236 | 52 |
let |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
53 |
val _ = print silent (fn () => "Testing " ^ n_facts (map fst facts) ^ "...") |
38100
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38094
diff
changeset
|
54 |
val params = |
41208
1b28c43a7074
make "debug" imply "blocking", since in blocking mode the exceptions flow through and are more instructive
blanchet
parents:
41138
diff
changeset
|
55 |
{debug = debug, verbose = false, overlord = overlord, blocking = true, |
41138
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41134
diff
changeset
|
56 |
provers = provers, type_sys = type_sys, explicit_apply = explicit_apply, |
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41134
diff
changeset
|
57 |
relevance_thresholds = (1.01, 1.01), max_relevant = NONE, |
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41134
diff
changeset
|
58 |
isar_proof = isar_proof, isar_shrink_factor = isar_shrink_factor, |
eb80538166b6
implemented partially-typed "tags" type encoding
blanchet
parents:
41134
diff
changeset
|
59 |
timeout = timeout, expect = ""} |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
60 |
val facts = |
41090 | 61 |
facts |> maps (fn (n, ths) => ths |> map (Untranslated_Fact o pair n)) |
40069 | 62 |
val {goal, ...} = Proof.goal state |
40065 | 63 |
val problem = |
64 |
{state = state, goal = goal, subgoal = i, subgoal_count = n, |
|
41242
8edeb1dbbc76
run the SMT relevance filter only once, then run the normalization/monomorphization code once _per class_ of SMT solvers
blanchet
parents:
41208
diff
changeset
|
65 |
facts = facts, smt_head = NONE} |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
66 |
val result as {outcome, used_facts, ...} = prover params (K "") problem |
36223
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36143
diff
changeset
|
67 |
in |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
68 |
print silent |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
69 |
(fn () => case outcome of |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
70 |
SOME failure => string_for_failure failure |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
71 |
| NONE => |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
72 |
if length used_facts = length facts then "Found proof." |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
73 |
else "Found proof with " ^ n_facts used_facts ^ "."); |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
74 |
result |
36223
217ca1273786
make Sledgehammer's minimizer also minimize Isar proofs
blanchet
parents:
36143
diff
changeset
|
75 |
end |
31236 | 76 |
|
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
77 |
(* minimalization of facts *) |
31236 | 78 |
|
40977 | 79 |
(* The sublinear algorithm works well in almost all situations, except when the |
80 |
external prover cannot return the list of used facts and hence returns all |
|
81 |
facts as used. In that case, the binary algorithm is much more |
|
82 |
appropriate. We can usually detect that situation just by looking at the |
|
83 |
number of used facts reported by the prover. *) |
|
84 |
val binary_threshold = 50 |
|
85 |
||
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
86 |
fun filter_used_facts used = filter (member (op =) used o fst) |
38015 | 87 |
|
88 |
fun sublinear_minimize _ [] p = p |
|
89 |
| sublinear_minimize test (x :: xs) (seen, result) = |
|
90 |
case test (xs @ seen) of |
|
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
91 |
result as {outcome = NONE, used_facts, ...} : prover_result => |
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
92 |
sublinear_minimize test (filter_used_facts used_facts xs) |
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
93 |
(filter_used_facts used_facts seen, result) |
38015 | 94 |
| _ => sublinear_minimize test xs (x :: seen, result) |
95 |
||
40977 | 96 |
fun binary_minimize test xs = |
97 |
let |
|
98 |
fun p xs = #outcome (test xs : prover_result) = NONE |
|
99 |
fun split [] p = p |
|
100 |
| split [h] (l, r) = (h :: l, r) |
|
101 |
| split (h1 :: h2 :: t) (l, r) = split t (h1 :: l, h2 :: r) |
|
102 |
fun min _ [] = raise Empty |
|
103 |
| min _ [s0] = [s0] |
|
104 |
| min sup xs = |
|
105 |
let val (l0, r0) = split xs ([], []) in |
|
106 |
if p (sup @ l0) then |
|
107 |
min sup l0 |
|
108 |
else if p (sup @ r0) then |
|
109 |
min sup r0 |
|
110 |
else |
|
111 |
let |
|
112 |
val l = min (sup @ r0) l0 |
|
113 |
val r = min (sup @ l) r0 |
|
114 |
in l @ r end |
|
115 |
end |
|
116 |
val xs = |
|
117 |
case min [] xs of |
|
118 |
[x] => if p [] then [] else [x] |
|
119 |
| xs => xs |
|
120 |
in (xs, test xs) end |
|
121 |
||
122 |
(* Give the external prover some slack. The ATP gets further slack because the |
|
123 |
Sledgehammer preprocessing time is included in the estimate below but isn't |
|
124 |
part of the timeout. *) |
|
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
125 |
val fudge_msecs = 1000 |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
126 |
|
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
127 |
fun minimize_facts {provers = [], ...} _ _ _ _ _ = error "No prover is set." |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
128 |
| minimize_facts (params as {provers = prover_name :: _, timeout, ...}) silent |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
129 |
i n state facts = |
31236 | 130 |
let |
36378 | 131 |
val thy = Proof.theory_of state |
40941
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40553
diff
changeset
|
132 |
val ctxt = Proof.context_of state |
a3e6f8634a11
replace "smt" prover with specific SMT solvers, e.g. "z3" -- whatever the SMT module gives us
blanchet
parents:
40553
diff
changeset
|
133 |
val prover = get_prover ctxt false prover_name |
38590
bd443b426d56
get rid of "minimize_timeout", now that there's an automatic adaptive timeout mechanism in "minimize"
blanchet
parents:
38589
diff
changeset
|
134 |
val msecs = Time.toMilliseconds timeout |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
135 |
val _ = print silent (fn () => "Sledgehammer minimize: " ^ |
40977 | 136 |
quote prover_name ^ ".") |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
137 |
val {goal, ...} = Proof.goal state |
38100
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38094
diff
changeset
|
138 |
val (_, hyp_ts, concl_t) = strip_subgoal goal i |
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38094
diff
changeset
|
139 |
val explicit_apply = |
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38094
diff
changeset
|
140 |
not (forall (Meson.is_fol_term thy) |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
141 |
(concl_t :: hyp_ts @ maps (map prop_of o snd) facts)) |
38100
e458a0dd3dc1
use "explicit_apply" in the minimizer whenever it might make a difference to prevent freak failures;
blanchet
parents:
38094
diff
changeset
|
142 |
fun do_test timeout = |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
143 |
test_facts params silent prover explicit_apply timeout i n state |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
144 |
val timer = Timer.startRealTimer () |
31236 | 145 |
in |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
146 |
(case do_test timeout facts of |
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
147 |
result as {outcome = NONE, used_facts, ...} => |
38015 | 148 |
let |
38092
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
149 |
val time = Timer.checkRealTimer timer |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
150 |
val new_timeout = |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
151 |
Int.min (msecs, Time.toMilliseconds time + fudge_msecs) |
81a003f7de0d
speed up the minimizer by using the time taken for the first iteration as a timeout for the following iterations, and fix a subtle bug in "string_for_failure"
blanchet
parents:
38084
diff
changeset
|
152 |
|> Time.fromMilliseconds |
40977 | 153 |
val facts = filter_used_facts used_facts facts |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
154 |
val (min_thms, {message, ...}) = |
40977 | 155 |
if length facts >= binary_threshold then |
156 |
binary_minimize (do_test new_timeout) facts |
|
157 |
else |
|
158 |
sublinear_minimize (do_test new_timeout) facts ([], result) |
|
38094 | 159 |
val n = length min_thms |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
160 |
val _ = print silent (fn () => cat_lines |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
161 |
["Minimized: " ^ string_of_int n ^ " fact" ^ plural_s n] ^ |
38752
6628adcae4a7
consider "locality" when assigning weights to facts
blanchet
parents:
38745
diff
changeset
|
162 |
(case length (filter (curry (op =) Chained o snd o fst) min_thms) of |
38698
d19c3a7ce38b
clean handling of whether a fact is chained or not;
blanchet
parents:
38696
diff
changeset
|
163 |
0 => "" |
d19c3a7ce38b
clean handling of whether a fact is chained or not;
blanchet
parents:
38696
diff
changeset
|
164 |
| n => " (including " ^ Int.toString n ^ " chained)") ^ ".") |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
165 |
in (SOME min_thms, message) end |
38015 | 166 |
| {outcome = SOME TimedOut, ...} => |
167 |
(NONE, "Timeout: You can increase the time limit using the \"timeout\" \ |
|
168 |
\option (e.g., \"timeout = " ^ |
|
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
40205
diff
changeset
|
169 |
string_of_int (10 + msecs div 1000) ^ "\").") |
38015 | 170 |
| {outcome = SOME UnknownError, ...} => |
171 |
(* Failure sometimes mean timeout, unfortunately. *) |
|
172 |
(NONE, "Failure: No proof was found with the current time limit. You \ |
|
173 |
\can increase the time limit using the \"timeout\" \ |
|
174 |
\option (e.g., \"timeout = " ^ |
|
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
40205
diff
changeset
|
175 |
string_of_int (10 + msecs div 1000) ^ "\").") |
40977 | 176 |
| {message, ...} => (NONE, "Prover error: " ^ message)) |
37994
b04307085a09
make TPTP generator accept full first-order formulas
blanchet
parents:
37926
diff
changeset
|
177 |
handle ERROR msg => (NONE, "Error: " ^ msg) |
31236 | 178 |
end |
179 |
||
38282
319c59682c51
move Sledgehammer's HOL -> FOL translation to separate file (sledgehammer_translate.ML)
blanchet
parents:
38100
diff
changeset
|
180 |
fun run_minimize params i refs state = |
38045 | 181 |
let |
182 |
val ctxt = Proof.context_of state |
|
38696
4c6b65d6a135
quote facts whose names collide with a keyword or command name (cf. "subclass" in "Jinja/J/TypeSafe.thy")
blanchet
parents:
38617
diff
changeset
|
183 |
val reserved = reserved_isar_keyword_table () |
38045 | 184 |
val chained_ths = #facts (Proof.goal state) |
40204
da97d75e20e6
standardize on "fact" terminology (vs. "axiom" or "theorem") in Sledgehammer -- but keep "Axiom" in the lower-level "ATP_Problem" module
blanchet
parents:
40200
diff
changeset
|
185 |
val facts = |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
186 |
refs |
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
187 |
|> maps (map (apsnd single) o fact_from_ref ctxt reserved chained_ths) |
38045 | 188 |
in |
189 |
case subgoal_count state of |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
40114
diff
changeset
|
190 |
0 => Output.urgent_message "No subgoal!" |
38045 | 191 |
| n => |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39496
diff
changeset
|
192 |
(kill_provers (); |
41091
0afdf5cde874
implicitly call the minimizer for SMT solvers that don't return an unsat core
blanchet
parents:
41090
diff
changeset
|
193 |
Output.urgent_message (#2 (minimize_facts params false i n state facts))) |
38045 | 194 |
end |
195 |
||
35866
513074557e06
move the Sledgehammer Isar commands together into one file;
blanchet
parents:
35865
diff
changeset
|
196 |
end; |