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