16 val helper_prefix : string |
16 val helper_prefix : string |
17 val class_rel_clause_prefix : string |
17 val class_rel_clause_prefix : string |
18 val arity_clause_prefix : string |
18 val arity_clause_prefix : string |
19 val tfrees_name : string |
19 val tfrees_name : string |
20 val prepare_axiom : |
20 val prepare_axiom : |
21 Proof.context -> (string * 'a) * thm -> ((string * 'a) * fol_formula) option |
21 Proof.context -> (string * 'a) * thm |
|
22 -> term * ((string * 'a) * fol_formula) option |
22 val prepare_problem : |
23 val prepare_problem : |
23 Proof.context -> bool -> bool -> bool -> bool -> term list -> term |
24 Proof.context -> bool -> bool -> bool -> bool -> term list -> term |
24 -> term list -> ((string * 'a) * fol_formula) option list |
25 -> (term * ((string * 'a) * fol_formula) option) list |
25 -> string problem * string Symtab.table * int * (string * 'a) list vector |
26 -> string problem * string Symtab.table * int * (string * 'a) list vector |
26 end; |
27 end; |
27 |
28 |
28 structure Sledgehammer_Translate : SLEDGEHAMMER_TRANSLATE = |
29 structure Sledgehammer_Translate : SLEDGEHAMMER_TRANSLATE = |
29 struct |
30 struct |
247 if exists is_needed ss then map baptize ths else [])) @ |
248 if exists is_needed ss then map baptize ths else [])) @ |
248 (if is_FO then [] else map baptize mandatory_helpers) |
249 (if is_FO then [] else map baptize mandatory_helpers) |
249 |> map_filter (Option.map snd o make_axiom ctxt false) |
250 |> map_filter (Option.map snd o make_axiom ctxt false) |
250 end |
251 end |
251 |
252 |
252 fun prepare_axiom ctxt = make_axiom ctxt true |
253 fun prepare_axiom ctxt (ax as (_, th)) = (prop_of th, make_axiom ctxt true ax) |
253 |
254 |
254 fun prepare_formulas ctxt full_types hyp_ts concl_t axiom_ts prepared_axioms = |
255 fun prepare_formulas ctxt full_types hyp_ts concl_t axioms = |
255 let |
256 let |
256 val thy = ProofContext.theory_of ctxt |
257 val thy = ProofContext.theory_of ctxt |
257 val hyp_ts = |
258 val (axiom_ts, prepared_axioms) = ListPair.unzip axioms |
258 (* Remove existing axioms from the conjecture, as this can dramatically |
259 (* Remove existing axioms from the conjecture, as this can dramatically |
259 boost an ATP's performance (for some reason). *) |
260 boost an ATP's performance (for some reason). *) |
260 hyp_ts |> filter_out (member (op aconv) axiom_ts) |
261 val hyp_ts = hyp_ts |> filter_out (member (op aconv) axiom_ts) |
261 val goal_t = Logic.list_implies (hyp_ts, concl_t) |
262 val goal_t = Logic.list_implies (hyp_ts, concl_t) |
262 val is_FO = Meson.is_fol_term thy goal_t |
263 val is_FO = Meson.is_fol_term thy goal_t |
263 val subs = tfree_classes_of_terms [goal_t] |
264 val subs = tfree_classes_of_terms [goal_t] |
264 val supers = tvar_classes_of_terms axiom_ts |
265 val supers = tvar_classes_of_terms axiom_ts |
265 val tycons = type_consts_of_terms thy (goal_t :: axiom_ts) |
266 val tycons = type_consts_of_terms thy (goal_t :: axiom_ts) |
496 fun repair_problem thy explicit_forall full_types explicit_apply problem = |
497 fun repair_problem thy explicit_forall full_types explicit_apply problem = |
497 repair_problem_with_const_table thy explicit_forall full_types |
498 repair_problem_with_const_table thy explicit_forall full_types |
498 (const_table_for_problem explicit_apply problem) problem |
499 (const_table_for_problem explicit_apply problem) problem |
499 |
500 |
500 fun prepare_problem ctxt readable_names explicit_forall full_types |
501 fun prepare_problem ctxt readable_names explicit_forall full_types |
501 explicit_apply hyp_ts concl_t axiom_ts prepared_axioms = |
502 explicit_apply hyp_ts concl_t axioms = |
502 let |
503 let |
503 val thy = ProofContext.theory_of ctxt |
504 val thy = ProofContext.theory_of ctxt |
504 val (axiom_names, (conjectures, axioms, helper_facts, class_rel_clauses, |
505 val (axiom_names, (conjectures, axioms, helper_facts, class_rel_clauses, |
505 arity_clauses)) = |
506 arity_clauses)) = |
506 prepare_formulas ctxt full_types hyp_ts concl_t axiom_ts prepared_axioms |
507 prepare_formulas ctxt full_types hyp_ts concl_t axioms |
507 val axiom_lines = map (problem_line_for_fact axiom_prefix full_types) axioms |
508 val axiom_lines = map (problem_line_for_fact axiom_prefix full_types) axioms |
508 val helper_lines = |
509 val helper_lines = |
509 map (problem_line_for_fact helper_prefix full_types) helper_facts |
510 map (problem_line_for_fact helper_prefix full_types) helper_facts |
510 val conjecture_lines = |
511 val conjecture_lines = |
511 map (problem_line_for_conjecture full_types) conjectures |
512 map (problem_line_for_conjecture full_types) conjectures |