22 Proof.context -> (string * stature) list vector -> string atp_proof -> |
22 Proof.context -> (string * stature) list vector -> string atp_proof -> |
23 (string * stature) list |
23 (string * stature) list |
24 val used_facts_in_unsound_atp_proof : |
24 val used_facts_in_unsound_atp_proof : |
25 Proof.context -> (string * stature) list vector -> 'a atp_proof -> |
25 Proof.context -> (string * stature) list vector -> 'a atp_proof -> |
26 string list option |
26 string list option |
27 val termify_atp_proof : |
|
28 Proof.context -> string Symtab.table -> (string * term) list -> |
|
29 int Symtab.table -> string atp_proof -> (term, string) atp_step list |
|
30 val isar_proof_text : |
27 val isar_proof_text : |
31 Proof.context -> bool option -> isar_params -> one_line_params -> string |
28 Proof.context -> bool option -> isar_params -> one_line_params -> string |
32 val proof_text : |
29 val proof_text : |
33 Proof.context -> bool option -> isar_params -> int -> one_line_params |
30 Proof.context -> bool option -> isar_params -> int -> one_line_params |
34 -> string |
31 -> string |
184 apsnd (union (op =) (map fst (resolve_fact fact_names ss))) |
181 apsnd (union (op =) (map fst (resolve_fact fact_names ss))) |
185 else |
182 else |
186 apfst (insert (op =) (label_of_clause names)) |
183 apfst (insert (op =) (label_of_clause names)) |
187 | add_fact_of_dependencies _ names = |
184 | add_fact_of_dependencies _ names = |
188 apfst (insert (op =) (label_of_clause names)) |
185 apfst (insert (op =) (label_of_clause names)) |
189 |
|
190 fun repair_name "$true" = "c_True" |
|
191 | repair_name "$false" = "c_False" |
|
192 | repair_name "$$e" = tptp_equal (* seen in Vampire proofs *) |
|
193 | repair_name s = |
|
194 if is_tptp_equal s orelse |
|
195 (* seen in Vampire proofs *) |
|
196 (String.isPrefix "sQ" s andalso String.isSuffix "_eqProxy" s) then |
|
197 tptp_equal |
|
198 else |
|
199 s |
|
200 |
|
201 fun infer_formula_types ctxt = |
|
202 Type.constraint HOLogic.boolT |
|
203 #> Syntax.check_term |
|
204 (Proof_Context.set_mode Proof_Context.mode_schematic ctxt) |
|
205 |
|
206 val combinator_table = |
|
207 [(@{const_name Meson.COMBI}, @{thm Meson.COMBI_def [abs_def]}), |
|
208 (@{const_name Meson.COMBK}, @{thm Meson.COMBK_def [abs_def]}), |
|
209 (@{const_name Meson.COMBB}, @{thm Meson.COMBB_def [abs_def]}), |
|
210 (@{const_name Meson.COMBC}, @{thm Meson.COMBC_def [abs_def]}), |
|
211 (@{const_name Meson.COMBS}, @{thm Meson.COMBS_def [abs_def]})] |
|
212 |
|
213 fun uncombine_term thy = |
|
214 let |
|
215 fun aux (t1 $ t2) = betapply (pairself aux (t1, t2)) |
|
216 | aux (Abs (s, T, t')) = Abs (s, T, aux t') |
|
217 | aux (t as Const (x as (s, _))) = |
|
218 (case AList.lookup (op =) combinator_table s of |
|
219 SOME thm => thm |> prop_of |> specialize_type thy x |
|
220 |> Logic.dest_equals |> snd |
|
221 | NONE => t) |
|
222 | aux t = t |
|
223 in aux end |
|
224 |
|
225 fun unlift_term lifted = |
|
226 map_aterms (fn t as Const (s, _) => |
|
227 if String.isPrefix lam_lifted_prefix s then |
|
228 case AList.lookup (op =) lifted s of |
|
229 SOME t => |
|
230 (* FIXME: do something about the types *) |
|
231 unlift_term lifted t |
|
232 | NONE => t |
|
233 else |
|
234 t |
|
235 | t => t) |
|
236 |
|
237 fun decode_line ctxt lifted sym_tab (name, role, u, rule, deps) = |
|
238 let |
|
239 val thy = Proof_Context.theory_of ctxt |
|
240 val t = |
|
241 u |> prop_of_atp ctxt true sym_tab |
|
242 |> uncombine_term thy |
|
243 |> unlift_term lifted |
|
244 |> infer_formula_types ctxt |
|
245 in (name, role, t, rule, deps) end |
|
246 |
186 |
247 fun replace_one_dependency (old, new) dep = |
187 fun replace_one_dependency (old, new) dep = |
248 if is_same_atp_step dep old then new else [dep] |
188 if is_same_atp_step dep old then new else [dep] |
249 fun replace_dependencies_in_line p (name, role, t, rule, deps) = |
189 fun replace_dependencies_in_line p (name, role, t, rule, deps) = |
250 (name, role, t, rule, fold (union (op =) o replace_one_dependency p) deps []) |
190 (name, role, t, rule, fold (union (op =) o replace_one_dependency p) deps []) |
280 (* Is there a repetition? If so, replace later line by earlier one. *) |
220 (* Is there a repetition? If so, replace later line by earlier one. *) |
281 else case take_prefix (not o is_same_inference (role, t)) lines of |
221 else case take_prefix (not o is_same_inference (role, t)) lines of |
282 (_, []) => line :: lines |
222 (_, []) => line :: lines |
283 | (pre, (name', _, _, _, _) :: post) => |
223 | (pre, (name', _, _, _, _) :: post) => |
284 line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
224 line :: pre @ map (replace_dependencies_in_line (name', [name])) post |
285 |
|
286 val waldmeister_conjecture_num = "1.0.0.0" |
|
287 |
|
288 fun repair_waldmeister_endgame arg = |
|
289 let |
|
290 fun do_tail (name, _, t, rule, deps) = |
|
291 (name, Negated_Conjecture, s_not t, rule, deps) |
|
292 fun do_body [] = [] |
|
293 | do_body ((line as ((num, _), _, _, _, _)) :: lines) = |
|
294 if num = waldmeister_conjecture_num then map do_tail (line :: lines) |
|
295 else line :: do_body lines |
|
296 in do_body arg end |
|
297 |
225 |
298 (* Recursively delete empty lines (type information) from the proof. *) |
226 (* Recursively delete empty lines (type information) from the proof. *) |
299 fun add_nontrivial_line (line as (name, _, t, _, [])) lines = |
227 fun add_nontrivial_line (line as (name, _, t, _, [])) lines = |
300 if is_only_type_information t then delete_dependency name lines |
228 if is_only_type_information t then delete_dependency name lines |
301 else line :: lines |
229 else line :: lines |
407 and chain_proof (Proof (fix, Assume assms, steps)) = |
335 and chain_proof (Proof (fix, Assume assms, steps)) = |
408 Proof (fix, Assume assms, |
336 Proof (fix, Assume assms, |
409 chain_steps (try (List.last #> fst) assms) steps) |
337 chain_steps (try (List.last #> fst) assms) steps) |
410 and chain_proofs proofs = map (chain_proof) proofs |
338 and chain_proofs proofs = map (chain_proof) proofs |
411 in chain_proof end |
339 in chain_proof end |
412 |
|
413 fun termify_atp_proof ctxt pool lifted sym_tab = |
|
414 clean_up_atp_proof_dependencies |
|
415 #> nasty_atp_proof pool |
|
416 #> map_term_names_in_atp_proof repair_name |
|
417 #> map (decode_line ctxt lifted sym_tab) |
|
418 #> repair_waldmeister_endgame |
|
419 |
340 |
420 type isar_params = |
341 type isar_params = |
421 bool * bool * Time.time option * real * bool * (string * stature) list vector |
342 bool * bool * Time.time option * real * bool * (string * stature) list vector |
422 * (unit -> (term, string) atp_step list) * thm |
343 * (unit -> (term, string) atp_step list) * thm |
423 |
344 |