8 type classrel_clause = Sledgehammer_FOL_Clause.classrel_clause |
8 type classrel_clause = Sledgehammer_FOL_Clause.classrel_clause |
9 type arity_clause = Sledgehammer_FOL_Clause.arity_clause |
9 type arity_clause = Sledgehammer_FOL_Clause.arity_clause |
10 type axiom_name = Sledgehammer_HOL_Clause.axiom_name |
10 type axiom_name = Sledgehammer_HOL_Clause.axiom_name |
11 type hol_clause = Sledgehammer_HOL_Clause.hol_clause |
11 type hol_clause = Sledgehammer_HOL_Clause.hol_clause |
12 type hol_clause_id = Sledgehammer_HOL_Clause.hol_clause_id |
12 type hol_clause_id = Sledgehammer_HOL_Clause.hol_clause_id |
|
13 |
13 type relevance_override = |
14 type relevance_override = |
14 {add: Facts.ref list, |
15 {add: Facts.ref list, |
15 del: Facts.ref list, |
16 del: Facts.ref list, |
16 only: bool} |
17 only: bool} |
17 |
18 |
18 val tvar_classes_of_terms : term list -> string list |
19 val tvar_classes_of_terms : term list -> string list |
19 val tfree_classes_of_terms : term list -> string list |
20 val tfree_classes_of_terms : term list -> string list |
20 val type_consts_of_terms : theory -> term list -> string list |
21 val type_consts_of_terms : theory -> term list -> string list |
21 val get_relevant_facts : |
22 val get_relevant_facts : |
22 bool -> real -> real -> bool option -> bool -> int -> bool |
23 bool -> real -> real -> bool -> int -> bool -> relevance_override |
23 -> relevance_override -> Proof.context * (thm list * 'a) -> thm list |
24 -> Proof.context * (thm list * 'a) -> thm list |
24 -> (thm * (string * int)) list |
25 -> (thm * (string * int)) list |
25 val prepare_clauses : bool option -> bool -> thm list -> thm list -> |
26 val prepare_clauses : |
26 (thm * (axiom_name * hol_clause_id)) list -> |
27 bool -> thm list -> thm list -> (thm * (axiom_name * hol_clause_id)) list |
27 (thm * (axiom_name * hol_clause_id)) list -> theory -> |
28 -> (thm * (axiom_name * hol_clause_id)) list -> theory |
28 axiom_name vector * |
29 -> axiom_name vector |
29 (hol_clause list * hol_clause list * hol_clause list * |
30 * (hol_clause list * hol_clause list * hol_clause list * |
30 hol_clause list * classrel_clause list * arity_clause list) |
31 hol_clause list * classrel_clause list * arity_clause list) |
31 end; |
32 end; |
32 |
33 |
33 structure Sledgehammer_Fact_Filter : SLEDGEHAMMER_FACT_FILTER = |
34 structure Sledgehammer_Fact_Filter : SLEDGEHAMMER_FACT_FILTER = |
34 struct |
35 struct |
35 |
36 |
498 |
499 |
499 (*Clauses containing variables of type "unit" or "bool" are unlikely to be useful and |
500 (*Clauses containing variables of type "unit" or "bool" are unlikely to be useful and |
500 likely to lead to unsound proofs.*) |
501 likely to lead to unsound proofs.*) |
501 fun remove_unwanted_clauses cls = filter (not o unwanted o prop_of o fst) cls; |
502 fun remove_unwanted_clauses cls = filter (not o unwanted o prop_of o fst) cls; |
502 |
503 |
503 fun is_first_order thy higher_order goal_cls = |
504 fun is_first_order thy = forall (Meson.is_fol_term thy) o map prop_of |
504 case higher_order of |
|
505 NONE => forall (Meson.is_fol_term thy) (map prop_of goal_cls) |
|
506 | SOME b => not b |
|
507 |
505 |
508 fun get_relevant_facts respect_no_atp relevance_threshold convergence |
506 fun get_relevant_facts respect_no_atp relevance_threshold convergence |
509 higher_order follow_defs max_new theory_relevant |
507 follow_defs max_new theory_relevant |
510 (relevance_override as {add, only, ...}) |
508 (relevance_override as {add, only, ...}) |
511 (ctxt, (chain_ths, th)) goal_cls = |
509 (ctxt, (chain_ths, th)) goal_cls = |
512 if (only andalso null add) orelse relevance_threshold > 1.0 then |
510 if (only andalso null add) orelse relevance_threshold > 1.0 then |
513 [] |
511 [] |
514 else |
512 else |
515 let |
513 let |
516 val thy = ProofContext.theory_of ctxt |
514 val thy = ProofContext.theory_of ctxt |
517 val is_FO = is_first_order thy higher_order goal_cls |
515 val is_FO = is_first_order thy goal_cls |
518 val included_cls = get_all_lemmas respect_no_atp ctxt |
516 val included_cls = get_all_lemmas respect_no_atp ctxt |
519 |> cnf_rules_pairs thy |> make_unique |
517 |> cnf_rules_pairs thy |> make_unique |
520 |> restrict_to_logic thy is_FO |
518 |> restrict_to_logic thy is_FO |
521 |> remove_unwanted_clauses |
519 |> remove_unwanted_clauses |
522 in |
520 in |
525 (map prop_of goal_cls) |
523 (map prop_of goal_cls) |
526 end |
524 end |
527 |
525 |
528 (* prepare for passing to writer, |
526 (* prepare for passing to writer, |
529 create additional clauses based on the information from extra_cls *) |
527 create additional clauses based on the information from extra_cls *) |
530 fun prepare_clauses higher_order dfg goal_cls chain_ths axcls extra_cls thy = |
528 fun prepare_clauses dfg goal_cls chain_ths axcls extra_cls thy = |
531 let |
529 let |
532 (* add chain thms *) |
530 (* add chain thms *) |
533 val chain_cls = |
531 val chain_cls = |
534 cnf_rules_pairs thy (filter check_named |
532 cnf_rules_pairs thy (filter check_named |
535 (map (`Thm.get_name_hint) chain_ths)) |
533 (map (`Thm.get_name_hint) chain_ths)) |
536 val axcls = chain_cls @ axcls |
534 val axcls = chain_cls @ axcls |
537 val extra_cls = chain_cls @ extra_cls |
535 val extra_cls = chain_cls @ extra_cls |
538 val is_FO = is_first_order thy higher_order goal_cls |
536 val is_FO = is_first_order thy goal_cls |
539 val ccls = subtract_cls extra_cls goal_cls |
537 val ccls = subtract_cls extra_cls goal_cls |
540 val _ = app (fn th => trace_msg (fn _ => Display.string_of_thm_global thy th)) ccls |
538 val _ = app (fn th => trace_msg (fn _ => Display.string_of_thm_global thy th)) ccls |
541 val ccltms = map prop_of ccls |
539 val ccltms = map prop_of ccls |
542 and axtms = map (prop_of o #1) extra_cls |
540 and axtms = map (prop_of o #1) extra_cls |
543 val subs = tfree_classes_of_terms ccltms |
541 val subs = tfree_classes_of_terms ccltms |