author | blanchet |
Wed, 17 Mar 2010 19:26:05 +0100 | |
changeset 35826 | 1590abc3d42a |
parent 35592 | 768d17f54125 |
child 35865 | 2f8fb5242799 |
permissions | -rw-r--r-- |
32327
0971cc0b6a57
src/HOL/Tools/ATP_Manager as separate component, with (almost) everything in one place;
wenzelm
parents:
32091
diff
changeset
|
1 |
(* Title: HOL/Tools/ATP_Manager/atp_minimal.ML |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
2 |
Author: Philipp Meyer, TU Muenchen |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
3 |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
4 |
Minimization of theorem list for metis by using an external automated theorem prover |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
5 |
*) |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
6 |
|
32525 | 7 |
signature ATP_MINIMAL = |
8 |
sig |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
9 |
val minimize: ATP_Wrapper.prover -> string -> int -> Proof.state -> |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
10 |
(string * thm list) list -> ((string * thm list) list * int) option * string |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
11 |
(* To be removed once TN has finished his measurements; |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
12 |
the int component of the result should then be removed: *) |
32936 | 13 |
val minimalize: ATP_Wrapper.prover -> string -> int -> Proof.state -> |
32571
d4bb776874b8
count number of iterations required for minimization (and fixed bug: minimization was always called)
nipkow
parents:
32538
diff
changeset
|
14 |
(string * thm list) list -> ((string * thm list) list * int) option * string |
32525 | 15 |
end |
16 |
||
32936 | 17 |
structure ATP_Minimal: ATP_MINIMAL = |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
18 |
struct |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
19 |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
20 |
(* Linear minimization *) |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
21 |
|
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
22 |
fun lin_gen_minimize p s = |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
23 |
let |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
24 |
fun min [] needed = needed |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
25 |
| min (x::xs) needed = |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
26 |
if p(xs @ needed) then min xs needed else min xs (x::needed) |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
27 |
in (min s [], length s) end; |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
28 |
|
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
29 |
(* Clever minimalization algorithm *) |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
30 |
|
31236 | 31 |
local |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
32 |
fun isplit (l, r) [] = (l, r) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
33 |
| isplit (l, r) [h] = (h :: l, r) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
34 |
| isplit (l, r) (h1 :: h2 :: t) = isplit (h1 :: l, h2 :: r) t |
31236 | 35 |
in |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
36 |
fun split lst = isplit ([], []) lst |
31236 | 37 |
end |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
38 |
|
31236 | 39 |
local |
40 |
fun min p sup [] = raise Empty |
|
41 |
| min p sup [s0] = [s0] |
|
42 |
| min p sup s = |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
43 |
let |
31236 | 44 |
val (l0, r0) = split s |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
45 |
in |
31236 | 46 |
if p (sup @ l0) |
47 |
then min p sup l0 |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
48 |
else |
31236 | 49 |
if p (sup @ r0) |
50 |
then min p sup r0 |
|
51 |
else |
|
52 |
let |
|
53 |
val l = min p (sup @ r0) l0 |
|
54 |
val r = min p (sup @ l) r0 |
|
55 |
in |
|
56 |
l @ r |
|
57 |
end |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
58 |
end |
31236 | 59 |
in |
60 |
(* return a minimal subset v of s that satisfies p |
|
61 |
@pre p(s) & ~p([]) & monotone(p) |
|
62 |
@post v subset s & p(v) & |
|
63 |
forall e in v. ~p(v \ e) |
|
64 |
*) |
|
32538
86035c5f61b5
Fixed "minimal" to cover the case that "p []" holds (excluded in the article by Bradley & Manna)
nipkow
parents:
32525
diff
changeset
|
65 |
fun minimal p s = |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
66 |
let |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
67 |
val count = Unsynchronized.ref 0 |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
68 |
fun p_count xs = (Unsynchronized.inc count; p xs) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
69 |
val v = |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
70 |
(case min p_count [] s of |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
71 |
[x] => if p_count [] then [] else [x] |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
72 |
| m => m); |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
73 |
in (v, ! count) end |
31236 | 74 |
end |
75 |
||
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
76 |
|
31236 | 77 |
(* failure check and producing answer *) |
78 |
||
79 |
datatype 'a prove_result = Success of 'a | Failure | Timeout | Error |
|
80 |
||
81 |
val string_of_result = |
|
82 |
fn Success _ => "Success" |
|
83 |
| Failure => "Failure" |
|
84 |
| Timeout => "Timeout" |
|
85 |
| Error => "Error" |
|
86 |
||
87 |
val failure_strings = |
|
88 |
[("SPASS beiseite: Ran out of time.", Timeout), |
|
89 |
("Timeout", Timeout), |
|
90 |
("time limit exceeded", Timeout), |
|
91 |
("# Cannot determine problem status within resource limit", Timeout), |
|
92 |
("Error", Error)] |
|
93 |
||
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32937
diff
changeset
|
94 |
fun produce_answer (result: ATP_Wrapper.prover_result) = |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
95 |
let |
32942
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
96 |
val {success, proof = result_string, internal_thm_names = thm_name_vec, |
b6711ec9de26
misc tuning and recovery of Isabelle coding style;
wenzelm
parents:
32941
diff
changeset
|
97 |
filtered_clauses = filtered, ...} = result |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
98 |
in |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
99 |
if success then |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
100 |
(Success (Vector.foldr (op ::) [] thm_name_vec, filtered), result_string) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
101 |
else |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
102 |
let |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
103 |
val failure = failure_strings |> get_first (fn (s, t) => |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
104 |
if String.isSubstring s result_string then SOME (t, result_string) else NONE) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
105 |
in |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
106 |
(case failure of |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
107 |
SOME res => res |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
108 |
| NONE => (Failure, result_string)) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
109 |
end |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
110 |
end |
31236 | 111 |
|
32936 | 112 |
|
31236 | 113 |
(* wrapper for calling external prover *) |
114 |
||
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
115 |
fun sh_test_thms prover time_limit subgoalno state filtered name_thms_pairs = |
31236 | 116 |
let |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
117 |
val _ = priority ("Testing " ^ string_of_int (length name_thms_pairs) ^ " theorems... ") |
32525 | 118 |
val name_thm_pairs = maps (fn (n, ths) => map (pair n) ths) name_thms_pairs |
35826 | 119 |
val axclauses = Sledgehammer_Fact_Preprocessor.cnf_rules_pairs (Proof.theory_of state) name_thm_pairs |
35592
768d17f54125
use regular Proof.goal (which is what methods usually see) and prevent sledgehammer from crashing;
wenzelm
parents:
33492
diff
changeset
|
120 |
val {context = ctxt, facts, goal} = Proof.goal state |
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32937
diff
changeset
|
121 |
val problem = |
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32937
diff
changeset
|
122 |
{with_full_types = ! ATP_Manager.full_types, |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
123 |
subgoal = subgoalno, |
33292 | 124 |
goal = (ctxt, (facts, goal)), |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
125 |
axiom_clauses = SOME axclauses, |
32941
72d48e333b77
eliminated extraneous wrapping of public records;
wenzelm
parents:
32937
diff
changeset
|
126 |
filtered_clauses = filtered} |
32948 | 127 |
val (result, proof) = produce_answer (prover time_limit problem) |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
128 |
val _ = priority (string_of_result result) |
31236 | 129 |
in |
130 |
(result, proof) |
|
131 |
end |
|
132 |
||
133 |
||
134 |
(* minimalization of thms *) |
|
135 |
||
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
136 |
fun gen_minimalize gen_min prover prover_name time_limit state name_thms_pairs = |
31236 | 137 |
let |
138 |
val _ = |
|
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
139 |
priority ("Minimize called with " ^ string_of_int (length name_thms_pairs) ^ |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
140 |
" theorems, prover: " ^ prover_name ^ |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
141 |
", time limit: " ^ string_of_int time_limit ^ " seconds") |
32864
a226f29d4bdc
re-organized signature of AtpWrapper structure: records instead of unnamed parameters and return values,
boehmes
parents:
32740
diff
changeset
|
142 |
val test_thms_fun = sh_test_thms prover time_limit 1 state |
31752
19a5f1c8a844
use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents:
31409
diff
changeset
|
143 |
fun test_thms filtered thms = |
19a5f1c8a844
use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents:
31409
diff
changeset
|
144 |
case test_thms_fun filtered thms of (Success _, _) => true | _ => false |
31236 | 145 |
in |
146 |
(* try prove first to check result and get used theorems *) |
|
31409
d8537ba165b5
split preparing clauses and writing problemfile;
immler@in.tum.de
parents:
31236
diff
changeset
|
147 |
(case test_thms_fun NONE name_thms_pairs of |
31752
19a5f1c8a844
use results of relevance-filter to determine additional clauses;
immler@in.tum.de
parents:
31409
diff
changeset
|
148 |
(Success (used, filtered), _) => |
31236 | 149 |
let |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
150 |
val ordered_used = sort_distinct string_ord used |
31236 | 151 |
val to_use = |
152 |
if length ordered_used < length name_thms_pairs then |
|
153 |
filter (fn (name1, _) => List.exists (equal name1) ordered_used) name_thms_pairs |
|
33305 | 154 |
else name_thms_pairs |
155 |
val (min_thms, n) = |
|
156 |
if null to_use then ([], 0) |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
157 |
else gen_min (test_thms (SOME filtered)) to_use |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
158 |
val min_names = sort_distinct string_ord (map fst min_thms) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
159 |
val _ = priority (cat_lines |
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
160 |
["Iterations: " ^ string_of_int n (* FIXME TN remove later *), |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
161 |
"Minimal " ^ string_of_int (length min_thms) ^ " theorems"]) |
31236 | 162 |
in |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
163 |
(SOME (min_thms, n), "Try this command: " ^ |
31236 | 164 |
Markup.markup Markup.sendback ("apply (metis " ^ space_implode " " min_names ^ ")")) |
165 |
end |
|
166 |
| (Timeout, _) => |
|
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
167 |
(NONE, "Timeout: You may need to increase the time limit of " ^ |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
168 |
string_of_int time_limit ^ " seconds. Call atp_minimize [time=...] ") |
31236 | 169 |
| (Error, msg) => |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
170 |
(NONE, "Error in prover: " ^ msg) |
31236 | 171 |
| (Failure, _) => |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
172 |
(NONE, "Failure: No proof with the theorems supplied")) |
35826 | 173 |
handle Sledgehammer_HOL_Clause.TOO_TRIVIAL => |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
174 |
(SOME ([], 0), "Trivial: Try this command: " ^ Markup.markup Markup.sendback "apply metis") |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
175 |
| ERROR msg => (NONE, "Error: " ^ msg) |
31236 | 176 |
end |
177 |
||
178 |
||
179 |
(* Isar command and parsing input *) |
|
180 |
||
181 |
local structure K = OuterKeyword and P = OuterParse and T = OuterLex in |
|
182 |
||
183 |
fun get_thms context = |
|
184 |
map (fn (name, interval) => |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
185 |
let |
31236 | 186 |
val thmref = Facts.Named ((name, Position.none), interval) |
187 |
val ths = ProofContext.get_fact context thmref |
|
188 |
val name' = Facts.string_of_ref thmref |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
189 |
in |
31236 | 190 |
(name', ths) |
191 |
end) |
|
192 |
||
193 |
val default_prover = "remote_vampire" |
|
194 |
val default_time_limit = 5 |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
195 |
|
31236 | 196 |
fun get_time_limit_arg time_string = |
197 |
(case Int.fromString time_string of |
|
198 |
SOME t => t |
|
199 |
| NONE => error ("Invalid time limit: " ^ quote time_string)) |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
200 |
|
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
201 |
fun get_opt (name, a) (p, t) = |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
202 |
(case name of |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
203 |
"time" => (p, get_time_limit_arg a) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
204 |
| "atp" => (a, t) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
205 |
| n => error ("Invalid argument: " ^ n)) |
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
206 |
|
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
207 |
fun get_options args = fold get_opt args (default_prover, default_time_limit) |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
208 |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
209 |
val minimize = gen_minimalize lin_gen_minimize |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
210 |
|
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
211 |
val minimalize = gen_minimalize minimal |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
212 |
|
31236 | 213 |
fun sh_min_command args thm_names state = |
214 |
let |
|
215 |
val (prover_name, time_limit) = get_options args |
|
216 |
val prover = |
|
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
217 |
(case ATP_Manager.get_prover (Proof.theory_of state) prover_name of |
31236 | 218 |
SOME prover => prover |
32947
3c19b98a35cd
ATP_Manager.get_prover: canonical argument order;
wenzelm
parents:
32942
diff
changeset
|
219 |
| NONE => error ("Unknown prover: " ^ quote prover_name)) |
31236 | 220 |
val name_thms_pairs = get_thms (Proof.context_of state) thm_names |
221 |
in |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
222 |
writeln (#2 (minimize prover prover_name time_limit state name_thms_pairs)) |
31236 | 223 |
end |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
224 |
|
33492
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
225 |
val parse_args = |
4168294a9f96
Command atp_minimize uses the naive linear algorithm now
nipkow
parents:
33316
diff
changeset
|
226 |
Scan.optional (Args.bracks (P.list (P.xname --| P.$$$ "=" -- P.xname))) [] |
31236 | 227 |
val parse_thm_names = Scan.repeat (P.xname -- Scan.option Attrib.thm_sel) |
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
228 |
|
31236 | 229 |
val _ = |
230 |
OuterSyntax.command "atp_minimize" "minimize theorem list with external prover" K.diag |
|
231 |
(parse_args -- parse_thm_names >> (fn (args, thm_names) => |
|
232 |
Toplevel.no_timing o Toplevel.unknown_proof o |
|
233 |
Toplevel.keep (sh_min_command args thm_names o Toplevel.proof_of))) |
|
31037
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
234 |
|
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
235 |
end |
ac8669134e7a
added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents:
diff
changeset
|
236 |
|
31236 | 237 |
end |