author | wenzelm |
Thu, 13 Aug 2015 11:05:19 +0200 | |
changeset 60924 | 610794dff23c |
parent 59582 | 0fbed69ff081 |
child 60978 | a0da65429a76 |
permissions | -rw-r--r-- |
55205 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_prover_atp.ML |
2 |
Author: Fabian Immler, TU Muenchen |
|
3 |
Author: Makarius |
|
4 |
Author: Jasmin Blanchette, TU Muenchen |
|
5 |
||
6 |
ATPs as Sledgehammer provers. |
|
7 |
*) |
|
8 |
||
9 |
signature SLEDGEHAMMER_PROVER_ATP = |
|
10 |
sig |
|
11 |
type mode = Sledgehammer_Prover.mode |
|
12 |
type prover = Sledgehammer_Prover.prover |
|
13 |
||
55212 | 14 |
val atp_dest_dir : string Config.T |
15 |
val atp_problem_prefix : string Config.T |
|
16 |
val atp_completish : bool Config.T |
|
17 |
val atp_full_names : bool Config.T |
|
18 |
||
19 |
val is_ho_atp : Proof.context -> string -> bool |
|
20 |
||
55205 | 21 |
val run_atp : mode -> string -> prover |
22 |
end; |
|
23 |
||
24 |
structure Sledgehammer_Prover_ATP : SLEDGEHAMMER_PROVER_ATP = |
|
25 |
struct |
|
26 |
||
27 |
open ATP_Util |
|
28 |
open ATP_Problem |
|
29 |
open ATP_Proof |
|
30 |
open ATP_Problem_Generate |
|
31 |
open ATP_Proof_Reconstruct |
|
57267
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
32 |
open ATP_Waldmeister |
57707
0242e9578828
imported patch satallax_proof_support_Sledgehammer
fleury
parents:
57671
diff
changeset
|
33 |
open ATP_Satallax |
55205 | 34 |
open ATP_Systems |
35 |
open Sledgehammer_Util |
|
55287 | 36 |
open Sledgehammer_Proof_Methods |
55205 | 37 |
open Sledgehammer_Isar |
38 |
open Sledgehammer_Prover |
|
39 |
||
55212 | 40 |
(* Empty string means create files in Isabelle's temporary files directory. *) |
41 |
val atp_dest_dir = Attrib.setup_config_string @{binding sledgehammer_atp_dest_dir} (K "") |
|
42 |
val atp_problem_prefix = |
|
43 |
Attrib.setup_config_string @{binding sledgehammer_atp_problem_prefix} (K "prob") |
|
44 |
val atp_completish = Attrib.setup_config_bool @{binding sledgehammer_atp_completish} (K false) |
|
45 |
(* In addition to being easier to read, readable names are often much shorter, especially if types |
|
46 |
are mangled in names. This makes a difference for some provers (e.g., E). For these reason, short |
|
47 |
names are enabled by default. *) |
|
48 |
val atp_full_names = Attrib.setup_config_bool @{binding sledgehammer_atp_full_names} (K false) |
|
49 |
||
50 |
fun is_atp_of_format is_format ctxt name = |
|
51 |
let val thy = Proof_Context.theory_of ctxt in |
|
52 |
(case try (get_atp thy) name of |
|
53 |
SOME config => |
|
54 |
exists (fn (_, ((_, format, _, _, _), _)) => is_format format) (#best_slices (config ()) ctxt) |
|
55 |
| NONE => false) |
|
56 |
end |
|
57 |
||
58 |
val is_ho_atp = is_atp_of_format is_format_higher_order |
|
59 |
||
55205 | 60 |
fun choose_type_enc strictness best_type_enc format = |
61 |
the_default best_type_enc |
|
62 |
#> type_enc_of_string strictness |
|
63 |
#> adjust_type_enc format |
|
64 |
||
65 |
fun has_bound_or_var_of_type pred = |
|
66 |
exists_subterm (fn Var (_, T as Type _) => pred T |
|
67 |
| Abs (_, T as Type _, _) => pred T |
|
68 |
| _ => false) |
|
69 |
||
70 |
(* Unwanted equalities are those between a (bound or schematic) variable that does not properly |
|
71 |
occur in the second operand. *) |
|
72 |
val is_exhaustive_finite = |
|
73 |
let |
|
74 |
fun is_bad_equal (Var z) t = |
|
75 |
not (exists_subterm (fn Var z' => z = z' | _ => false) t) |
|
76 |
| is_bad_equal (Bound j) t = not (loose_bvar1 (t, j)) |
|
77 |
| is_bad_equal _ _ = false |
|
78 |
fun do_equals t1 t2 = is_bad_equal t1 t2 orelse is_bad_equal t2 t1 |
|
79 |
fun do_formula pos t = |
|
55208 | 80 |
(case (pos, t) of |
55205 | 81 |
(_, @{const Trueprop} $ t1) => do_formula pos t1 |
56245 | 82 |
| (true, Const (@{const_name Pure.all}, _) $ Abs (_, _, t')) => do_formula pos t' |
55208 | 83 |
| (true, Const (@{const_name All}, _) $ Abs (_, _, t')) => do_formula pos t' |
84 |
| (false, Const (@{const_name Ex}, _) $ Abs (_, _, t')) => do_formula pos t' |
|
56245 | 85 |
| (_, @{const Pure.imp} $ t1 $ t2) => |
55208 | 86 |
do_formula (not pos) t1 andalso (t2 = @{prop False} orelse do_formula pos t2) |
55205 | 87 |
| (_, @{const HOL.implies} $ t1 $ t2) => |
55208 | 88 |
do_formula (not pos) t1 andalso (t2 = @{const False} orelse do_formula pos t2) |
55205 | 89 |
| (_, @{const Not} $ t1) => do_formula (not pos) t1 |
90 |
| (true, @{const HOL.disj} $ t1 $ t2) => forall (do_formula pos) [t1, t2] |
|
91 |
| (false, @{const HOL.conj} $ t1 $ t2) => forall (do_formula pos) [t1, t2] |
|
92 |
| (true, Const (@{const_name HOL.eq}, _) $ t1 $ t2) => do_equals t1 t2 |
|
56245 | 93 |
| (true, Const (@{const_name Pure.eq}, _) $ t1 $ t2) => do_equals t1 t2 |
55208 | 94 |
| _ => false) |
55205 | 95 |
in do_formula true end |
96 |
||
97 |
(* Facts containing variables of finite types such as "unit" or "bool" or of the form |
|
98 |
"ALL x. x = A | x = B | x = C" are likely to lead to untypable proofs for unsound type |
|
99 |
encodings. *) |
|
100 |
fun is_dangerous_prop ctxt = |
|
101 |
transform_elim_prop |
|
102 |
#> (has_bound_or_var_of_type (is_type_surely_finite ctxt) orf is_exhaustive_finite) |
|
103 |
||
104 |
fun get_slices slice slices = |
|
105 |
(0 upto length slices - 1) ~~ slices |> not slice ? (List.last #> single) |
|
106 |
||
107 |
fun get_facts_of_filter _ [(_, facts)] = facts |
|
108 |
| get_facts_of_filter fact_filter factss = |
|
109 |
(case AList.lookup (op =) factss fact_filter of |
|
110 |
SOME facts => facts |
|
111 |
| NONE => snd (hd factss)) |
|
112 |
||
113 |
(* For low values of "max_facts", this fudge value ensures that most slices are invoked with a |
|
114 |
nontrivial amount of facts. *) |
|
115 |
val max_fact_factor_fudge = 5 |
|
116 |
||
117 |
val mono_max_privileged_facts = 10 |
|
118 |
||
119 |
fun suffix_of_mode Auto_Try = "_try" |
|
120 |
| suffix_of_mode Try = "_try" |
|
121 |
| suffix_of_mode Normal = "" |
|
122 |
| suffix_of_mode MaSh = "" |
|
123 |
| suffix_of_mode Minimize = "_min" |
|
124 |
||
125 |
(* Give the ATPs some slack before interrupting them the hard way. "z3_tptp" on Linux appears to be |
|
126 |
the only ATP that does not honor its time limit. *) |
|
127 |
val atp_timeout_slack = seconds 1.0 |
|
128 |
||
57738 | 129 |
(* Important messages are important but not so important that users want to see them each time. *) |
55205 | 130 |
val atp_important_message_keep_quotient = 25 |
131 |
||
132 |
fun run_atp mode name |
|
57732 | 133 |
({debug, verbose, overlord, type_enc, strict, lam_trans, uncurried_aliases, fact_filter, |
134 |
max_facts, max_mono_iters, max_new_mono_instances, isar_proofs, compress, try0, smt_proofs, |
|
135 |
slice, minimize, timeout, preplay_timeout, ...} : params) |
|
55205 | 136 |
({comment, state, goal, subgoal, subgoal_count, factss, ...} : prover_problem) = |
137 |
let |
|
138 |
val thy = Proof.theory_of state |
|
139 |
val ctxt = Proof.context_of state |
|
140 |
||
141 |
val {exec, arguments, proof_delims, known_failures, prem_role, best_slices, best_max_mono_iters, |
|
142 |
best_max_new_mono_instances, ...} = get_atp thy name () |
|
143 |
||
57671
dc5e1b1db9ba
avoid 'eproof' and 'eproof_ram' scripts if possible (i.e. if 'eprover' can produce reasonable enough proofs for one-liner reconstruction)
blanchet
parents:
57460
diff
changeset
|
144 |
val full_proofs = isar_proofs |> the_default (mode = Minimize) |
57267
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
145 |
val local_name = perhaps (try (unprefix remote_prefix)) name |
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
146 |
val waldmeister_new = (local_name = waldmeister_newN) |
59577 | 147 |
val spassy = (local_name = pirateN orelse local_name = spassN) |
57267
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
148 |
|
55212 | 149 |
val atp_mode = if Config.get ctxt atp_completish then Sledgehammer_Completish else Sledgehammer |
55205 | 150 |
val (_, hyp_ts, concl_t) = strip_subgoal goal subgoal ctxt |
151 |
val (dest_dir, problem_prefix) = |
|
152 |
if overlord then overlord_file_location_of_prover name |
|
55212 | 153 |
else (Config.get ctxt atp_dest_dir, Config.get ctxt atp_problem_prefix) |
55205 | 154 |
val problem_file_name = |
155 |
Path.basic (problem_prefix ^ (if overlord then "" else serial_string ()) ^ |
|
58085 | 156 |
suffix_of_mode mode ^ "_" ^ string_of_int subgoal) |
55205 | 157 |
val prob_path = |
158 |
if dest_dir = "" then |
|
159 |
File.tmp_path problem_file_name |
|
160 |
else if File.exists (Path.explode dest_dir) then |
|
161 |
Path.append (Path.explode dest_dir) problem_file_name |
|
162 |
else |
|
163 |
error ("No such directory: " ^ quote dest_dir ^ ".") |
|
57671
dc5e1b1db9ba
avoid 'eproof' and 'eproof_ram' scripts if possible (i.e. if 'eprover' can produce reasonable enough proofs for one-liner reconstruction)
blanchet
parents:
57460
diff
changeset
|
164 |
val exec = exec full_proofs |
55205 | 165 |
val command0 = |
55208 | 166 |
(case find_first (fn var => getenv var <> "") (fst exec) of |
55205 | 167 |
SOME var => |
168 |
let |
|
169 |
val pref = getenv var ^ "/" |
|
170 |
val paths = map (Path.explode o prefix pref) (snd exec) |
|
171 |
in |
|
55208 | 172 |
(case find_first File.exists paths of |
55205 | 173 |
SOME path => path |
55208 | 174 |
| NONE => error ("Bad executable: " ^ Path.print (hd paths) ^ ".")) |
55205 | 175 |
end |
55208 | 176 |
| NONE => error ("The environment variable " ^ quote (List.last (fst exec)) ^ " is not set.")) |
55205 | 177 |
|
178 |
fun split_time s = |
|
179 |
let |
|
180 |
val split = String.tokens (fn c => str c = "\n") |
|
55249 | 181 |
val (output, t) = s |> split |> (try split_last #> the_default ([], "0")) |>> cat_lines |
182 |
val num = Scan.many1 Symbol.is_ascii_digit >> (fst o read_int) |
|
55205 | 183 |
val digit = Scan.one Symbol.is_ascii_digit |
55249 | 184 |
val num3 = digit ::: digit ::: (digit >> single) >> (fst o read_int) |
55205 | 185 |
val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b) |
55249 | 186 |
val as_time = raw_explode #> Scan.read Symbol.stopper time #> the_default 0 |
55205 | 187 |
in (output, as_time t |> Time.fromMilliseconds) end |
188 |
||
189 |
fun run () = |
|
190 |
let |
|
55208 | 191 |
(* If slicing is disabled, we expand the last slice to fill the entire time available. *) |
55205 | 192 |
val all_slices = best_slices ctxt |
193 |
val actual_slices = get_slices slice all_slices |
|
55276 | 194 |
|
195 |
fun max_facts_of_slices (slices : (real * (slice_spec * string)) list) = |
|
196 |
fold (Integer.max o fst o #1 o fst o snd) slices 0 |
|
197 |
||
55205 | 198 |
val num_actual_slices = length actual_slices |
199 |
val max_fact_factor = |
|
55248 | 200 |
Real.fromInt (case max_facts of NONE => max_facts_of_slices all_slices | SOME max => max) |
201 |
/ Real.fromInt (max_facts_of_slices (map snd actual_slices)) |
|
55212 | 202 |
|
55205 | 203 |
fun monomorphize_facts facts = |
204 |
let |
|
205 |
val ctxt = |
|
206 |
ctxt |
|
207 |
|> repair_monomorph_context max_mono_iters best_max_mono_iters max_new_mono_instances |
|
208 |
best_max_new_mono_instances |
|
209 |
(* pseudo-theorem involving the same constants as the subgoal *) |
|
210 |
val subgoal_th = |
|
211 |
Logic.list_implies (hyp_ts, concl_t) |> Skip_Proof.make_thm thy |
|
212 |
val rths = |
|
213 |
facts |> chop mono_max_privileged_facts |
|
214 |
|>> map (pair 1 o snd) |
|
215 |
||> map (pair 2 o snd) |
|
216 |
|> op @ |
|
217 |
|> cons (0, subgoal_th) |
|
218 |
in |
|
219 |
Monomorph.monomorph atp_schematic_consts_of ctxt rths |
|
220 |
|> tl |> curry ListPair.zip (map fst facts) |
|
55208 | 221 |
|> maps (fn (name, rths) => map (pair name o zero_var_indexes o snd) rths) |
55205 | 222 |
end |
223 |
||
55208 | 224 |
fun run_slice time_left (cache_key, cache_value) (slice, (time_frac, |
225 |
(key as ((best_max_facts, best_fact_filter), format, best_type_enc, best_lam_trans, |
|
55249 | 226 |
best_uncurried_aliases), |
55208 | 227 |
extra))) = |
55205 | 228 |
let |
55208 | 229 |
val effective_fact_filter = fact_filter |> the_default best_fact_filter |
55205 | 230 |
val facts = get_facts_of_filter effective_fact_filter factss |
231 |
val num_facts = |
|
232 |
Real.ceil (max_fact_factor * Real.fromInt best_max_facts) + max_fact_factor_fudge |
|
233 |
|> Integer.min (length facts) |
|
234 |
val strictness = if strict then Strict else Non_Strict |
|
235 |
val type_enc = type_enc |> choose_type_enc strictness best_type_enc format |
|
236 |
val sound = is_type_enc_sound type_enc |
|
237 |
val real_ms = Real.fromInt o Time.toMilliseconds |
|
238 |
val slice_timeout = |
|
239 |
(real_ms time_left |
|
240 |
|> (if slice < num_actual_slices - 1 then |
|
241 |
curry Real.min (time_frac * real_ms timeout) |
|
242 |
else |
|
243 |
I)) |
|
244 |
* 0.001 |
|
245 |
|> seconds |
|
246 |
val generous_slice_timeout = |
|
247 |
if mode = MaSh then one_day else Time.+ (slice_timeout, atp_timeout_slack) |
|
248 |
val _ = |
|
249 |
if debug then |
|
250 |
quote name ^ " slice #" ^ string_of_int (slice + 1) ^ |
|
251 |
" with " ^ string_of_int num_facts ^ " fact" ^ |
|
252 |
plural_s num_facts ^ " for " ^ string_of_time slice_timeout ^ "..." |
|
58843 | 253 |
|> writeln |
55205 | 254 |
else |
255 |
() |
|
256 |
val readable_names = not (Config.get ctxt atp_full_names) |
|
55208 | 257 |
val lam_trans = lam_trans |> the_default best_lam_trans |
258 |
val uncurried_aliases = uncurried_aliases |> the_default best_uncurried_aliases |
|
58142 | 259 |
val value as (atp_problem, _, _, _, _) = |
55205 | 260 |
if cache_key = SOME key then |
261 |
cache_value |
|
262 |
else |
|
263 |
facts |
|
59582 | 264 |
|> not sound ? filter_out (is_dangerous_prop ctxt o Thm.prop_of o snd) |
55205 | 265 |
|> take num_facts |
266 |
|> not (is_type_enc_polymorphic type_enc) ? monomorphize_facts |
|
59582 | 267 |
|> map (apsnd Thm.prop_of) |
57267
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
268 |
|> (if waldmeister_new then |
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
269 |
generate_waldmeister_problem ctxt hyp_ts concl_t |
58142 | 270 |
#> (fn (a,b,c,d,e) => (a,b,c,d,SOME e)) |
57267
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
271 |
else |
8b87114357bd
integrated new Waldmeister code with 'sledgehammer' command
blanchet
parents:
57266
diff
changeset
|
272 |
generate_atp_problem ctxt format prem_role type_enc atp_mode lam_trans |
58142 | 273 |
uncurried_aliases readable_names true hyp_ts concl_t |
274 |
#> (fn (a,b,c,d) => (a,b,c,d,NONE))) |
|
55205 | 275 |
|
276 |
fun sel_weights () = atp_problem_selection_weights atp_problem |
|
277 |
fun ord_info () = atp_problem_term_order_info atp_problem |
|
278 |
||
279 |
val ord = effective_term_order ctxt name |
|
280 |
val args = |
|
57671
dc5e1b1db9ba
avoid 'eproof' and 'eproof_ram' scripts if possible (i.e. if 'eprover' can produce reasonable enough proofs for one-liner reconstruction)
blanchet
parents:
57460
diff
changeset
|
281 |
arguments ctxt full_proofs extra slice_timeout (File.shell_path prob_path) |
55205 | 282 |
(ord, ord_info, sel_weights) |
283 |
val command = |
|
284 |
"(exec 2>&1; " ^ File.shell_path command0 ^ " " ^ args ^ " " ^ ")" |
|
285 |
|> enclose "TIMEFORMAT='%3R'; { time " " ; }" |
|
57263 | 286 |
|
55205 | 287 |
val _ = |
288 |
atp_problem |
|
289 |
|> lines_of_atp_problem format ord ord_info |
|
290 |
|> cons ("% " ^ command ^ "\n" ^ (if comment = "" then "" else "% " ^ comment ^ "\n")) |
|
291 |
|> File.write_list prob_path |
|
57263 | 292 |
|
55205 | 293 |
val ((output, run_time), (atp_proof, outcome)) = |
294 |
TimeLimit.timeLimit generous_slice_timeout Isabelle_System.bash_output command |
|
295 |
|>> (if overlord then prefix ("% " ^ command ^ "\n% " ^ timestamp () ^ "\n") else I) |
|
296 |
|> fst |> split_time |
|
297 |
|> (fn accum as (output, _) => |
|
57776
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
298 |
(accum, |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
299 |
extract_tstplike_proof_and_outcome verbose proof_delims known_failures output |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
300 |
|>> atp_proof_of_tstplike_proof (perhaps (try (unprefix remote_prefix)) name) |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
301 |
atp_problem |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
302 |
handle UNRECOGNIZED_ATP_PROOF () => ([], SOME ProofUnparsable))) |
55205 | 303 |
handle TimeLimit.TimeOut => (("", slice_timeout), ([], SOME TimedOut)) |
57263 | 304 |
|
55205 | 305 |
val outcome = |
306 |
(case outcome of |
|
307 |
NONE => |
|
57776
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
308 |
(case used_facts_in_unsound_atp_proof ctxt (map fst facts) atp_proof of |
55208 | 309 |
SOME facts => |
57776
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
310 |
let |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
311 |
val failure = UnsoundProof (is_type_enc_sound type_enc, sort string_ord facts) |
1111a9a328fe
rationalized sorting of facts -- so that preplaying (almost always) coincides with the real thing, preventing odd failures
blanchet
parents:
57750
diff
changeset
|
312 |
in |
55208 | 313 |
if debug then (warning (string_of_atp_failure failure); NONE) else SOME failure |
314 |
end |
|
315 |
| NONE => NONE) |
|
55205 | 316 |
| _ => outcome) |
317 |
in |
|
57255
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
318 |
((SOME key, value), (output, run_time, facts, atp_proof, outcome), |
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
319 |
SOME (format, type_enc)) |
55205 | 320 |
end |
321 |
||
322 |
val timer = Timer.startRealTimer () |
|
323 |
||
57255
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
324 |
fun maybe_run_slice slice (result as (cache, (_, run_time0, _, _, SOME _), _)) = |
55208 | 325 |
let val time_left = Time.- (timeout, Timer.checkRealTimer timer) in |
55205 | 326 |
if Time.<= (time_left, Time.zeroTime) then |
327 |
result |
|
328 |
else |
|
329 |
run_slice time_left cache slice |
|
57255
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
330 |
|> (fn (cache, (output, run_time, used_from, atp_proof, outcome), |
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
331 |
format_type_enc) => |
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
332 |
(cache, (output, Time.+ (run_time0, run_time), used_from, atp_proof, outcome), |
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
333 |
format_type_enc)) |
55205 | 334 |
end |
335 |
| maybe_run_slice _ result = result |
|
336 |
in |
|
58142 | 337 |
((NONE, ([], Symtab.empty, [], Symtab.empty,NONE)), |
57255
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
338 |
("", Time.zeroTime, [], [], SOME InternalError), NONE) |
55205 | 339 |
|> fold maybe_run_slice actual_slices |
340 |
end |
|
341 |
||
342 |
(* If the problem file has not been exported, remove it; otherwise, export |
|
343 |
the proof file too. *) |
|
55208 | 344 |
fun clean_up () = if dest_dir = "" then (try File.rm prob_path; ()) else () |
57255
488046fdda59
add support for Isar reconstruction for thf1 ATP provers like Leo-II.
fleury
parents:
57245
diff
changeset
|
345 |
fun export (_, (output, _, _, _, _), _) = |
55205 | 346 |
if dest_dir = "" then () |
347 |
else File.write (Path.explode (Path.implode prob_path ^ "_proof")) output |
|
55208 | 348 |
|
58142 | 349 |
val ((_, (_, pool, lifted, sym_tab,wm_info)), (output, run_time, used_from, atp_proof, outcome), |
57263 | 350 |
SOME (format, type_enc)) = |
55205 | 351 |
with_cleanup clean_up run () |> tap export |
55208 | 352 |
|
55205 | 353 |
val important_message = |
59172 | 354 |
if mode = Normal andalso Random.random_range 0 (atp_important_message_keep_quotient - 1) = 0 |
355 |
then extract_important_message output |
|
356 |
else "" |
|
55205 | 357 |
|
57738 | 358 |
val (used_facts, preferred_methss, message) = |
55205 | 359 |
(case outcome of |
360 |
NONE => |
|
361 |
let |
|
60924
610794dff23c
tuned signature, in accordance to sortBy in Scala;
wenzelm
parents:
59582
diff
changeset
|
362 |
val used_facts = sort_by fst (used_facts_in_atp_proof ctxt (map fst used_from) atp_proof) |
55205 | 363 |
val needs_full_types = is_typed_helper_used_in_atp_proof atp_proof |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57732
diff
changeset
|
364 |
val preferred_methss = |
57778
cf4215911f85
default on 'metis' for ATPs if preplaying is disabled
blanchet
parents:
57776
diff
changeset
|
365 |
(Metis_Method (NONE, NONE), |
cf4215911f85
default on 'metis' for ATPs if preplaying is disabled
blanchet
parents:
57776
diff
changeset
|
366 |
bunches_of_proof_methods try0 (smt_proofs <> SOME false) needs_full_types |
cf4215911f85
default on 'metis' for ATPs if preplaying is disabled
blanchet
parents:
57776
diff
changeset
|
367 |
(if atp_proof_prefers_lifting atp_proof then liftingN else hide_lamsN)) |
55205 | 368 |
in |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57732
diff
changeset
|
369 |
(used_facts, preferred_methss, |
55205 | 370 |
fn preplay => |
371 |
let |
|
58843 | 372 |
val _ = if verbose then writeln "Generating proof text..." else () |
57263 | 373 |
|
55205 | 374 |
fun isar_params () = |
375 |
let |
|
376 |
val metis_type_enc = |
|
55257 | 377 |
if is_typed_helper_used_in_atp_proof atp_proof then SOME full_typesN else NONE |
378 |
val metis_lam_trans = |
|
379 |
if atp_proof_prefers_lifting atp_proof then SOME liftingN else NONE |
|
55205 | 380 |
val atp_proof = |
381 |
atp_proof |
|
58142 | 382 |
|> (if waldmeister_new then termify_waldmeister_proof ctxt pool |
383 |
else termify_atp_proof ctxt name format type_enc pool lifted sym_tab) |
|
59577 | 384 |
|> spassy ? introduce_spassy_skolems |
58246
c723f55747fb
Fixed bug which broke isar proof construction for all ATPs except Waldmeister_new
steckerm
parents:
58142
diff
changeset
|
385 |
|> (if waldmeister_new then introduce_waldmeister_skolems (the wm_info) else I) |
57263 | 386 |
|> factify_atp_proof (map fst used_from) hyp_ts concl_t |
55205 | 387 |
in |
57245 | 388 |
(verbose, (metis_type_enc, metis_lam_trans), preplay_timeout, compress, try0, |
57721 | 389 |
minimize, atp_proof, goal) |
55205 | 390 |
end |
57263 | 391 |
|
57750 | 392 |
val one_line_params = (preplay (), proof_banner mode name, subgoal, subgoal_count) |
55205 | 393 |
val num_chained = length (#facts (Proof.goal state)) |
394 |
in |
|
57738 | 395 |
proof_text ctxt debug isar_proofs smt_proofs isar_params num_chained |
396 |
one_line_params ^ |
|
397 |
(if important_message <> "" then |
|
398 |
"\n\nImportant message from Dr. Geoff Sutcliffe:\n" ^ important_message |
|
399 |
else |
|
400 |
"") |
|
401 |
end) |
|
55205 | 402 |
end |
403 |
| SOME failure => |
|
57738 | 404 |
([], (Auto_Method (* dummy *), []), fn _ => string_of_atp_failure failure)) |
55205 | 405 |
in |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57732
diff
changeset
|
406 |
{outcome = outcome, used_facts = used_facts, used_from = used_from, |
57738 | 407 |
preferred_methss = preferred_methss, run_time = run_time, message = message} |
55205 | 408 |
end |
409 |
||
58142 | 410 |
end; |