29 val build_name_tables : (thm -> string) -> ('a * thm) list -> |
29 val build_name_tables : (thm -> string) -> ('a * thm) list -> |
30 string Symtab.table * string Symtab.table |
30 string Symtab.table * string Symtab.table |
31 val maybe_instantiate_inducts : Proof.context -> term list -> term -> |
31 val maybe_instantiate_inducts : Proof.context -> term list -> term -> |
32 (((unit -> string) * 'a) * thm) list -> (((unit -> string) * 'a) * thm) list |
32 (((unit -> string) * 'a) * thm) list -> (((unit -> string) * 'a) * thm) list |
33 val fact_of_raw_fact : raw_fact -> fact |
33 val fact_of_raw_fact : raw_fact -> fact |
|
34 val is_useful_unnamed_local_fact : Proof.context -> thm -> bool |
34 |
35 |
35 val all_facts : Proof.context -> bool -> bool -> unit Symtab.table -> thm list -> thm list -> |
36 val all_facts : Proof.context -> bool -> bool -> unit Symtab.table -> thm list -> thm list -> |
36 status Termtab.table -> raw_fact list |
37 status Termtab.table -> raw_fact list |
37 val nearly_all_facts : Proof.context -> bool -> fact_override -> unit Symtab.table -> |
38 val nearly_all_facts : Proof.context -> bool -> fact_override -> unit Symtab.table -> |
38 status Termtab.table -> thm list -> term list -> term -> raw_fact list |
39 status Termtab.table -> thm list -> term list -> term -> raw_fact list |
440 |
441 |
441 fun fact_of_raw_fact ((name, stature), th) = ((name (), stature), th) |
442 fun fact_of_raw_fact ((name, stature), th) = ((name (), stature), th) |
442 |
443 |
443 fun fact_count facts = Facts.fold_static (K (Integer.add 1)) facts 0 |
444 fun fact_count facts = Facts.fold_static (K (Integer.add 1)) facts 0 |
444 |
445 |
|
446 fun is_useful_unnamed_local_fact ctxt = |
|
447 let |
|
448 val thy = Proof_Context.theory_of ctxt |
|
449 val global_facts = Global_Theory.facts_of thy |
|
450 val local_facts = Proof_Context.facts_of ctxt |
|
451 val named_locals = Facts.dest_static true [global_facts] local_facts |
|
452 in |
|
453 fn th => |
|
454 not (Thm.has_name_hint th) andalso |
|
455 forall (fn (_, ths) => not (member Thm.eq_thm_prop ths th)) named_locals |
|
456 end |
|
457 |
445 fun all_facts ctxt generous ho_atp reserved add_ths chained css = |
458 fun all_facts ctxt generous ho_atp reserved add_ths chained css = |
446 let |
459 let |
447 val thy = Proof_Context.theory_of ctxt |
460 val thy = Proof_Context.theory_of ctxt |
448 val global_facts = Global_Theory.facts_of thy |
461 val global_facts = Global_Theory.facts_of thy |
449 val is_too_complex = |
462 val is_too_complex = |
450 if generous orelse fact_count global_facts >= max_facts_for_complex_check then K false |
463 if generous orelse fact_count global_facts >= max_facts_for_complex_check then K false |
451 else is_too_complex |
464 else is_too_complex |
452 val local_facts = Proof_Context.facts_of ctxt |
465 val local_facts = Proof_Context.facts_of ctxt |
453 val named_locals = local_facts |> Facts.dest_static true [global_facts] |
|
454 val assms = Assumption.all_assms_of ctxt |
466 val assms = Assumption.all_assms_of ctxt |
455 |
467 val named_locals = Facts.dest_static true [global_facts] local_facts |
456 fun is_good_unnamed_local th = |
|
457 not (Thm.has_name_hint th) andalso |
|
458 forall (fn (_, ths) => not (member Thm.eq_thm_prop ths th)) named_locals |
|
459 |
|
460 val unnamed_locals = |
468 val unnamed_locals = |
461 union Thm.eq_thm_prop (Facts.props local_facts) chained |
469 Facts.props local_facts |
462 |> filter is_good_unnamed_local |> map (pair "" o single) |
470 |> filter (is_useful_unnamed_local_fact ctxt) |
|
471 |> map (pair "" o single) |
|
472 |
463 val full_space = Name_Space.merge (Facts.space_of global_facts, Facts.space_of local_facts) |
473 val full_space = Name_Space.merge (Facts.space_of global_facts, Facts.space_of local_facts) |
464 val is_blacklisted_or_something = is_blacklisted_or_something ctxt ho_atp |
474 val is_blacklisted_or_something = is_blacklisted_or_something ctxt ho_atp |
465 |
475 |
466 fun add_facts global foldx facts = |
476 fun add_facts global foldx facts = |
467 foldx (fn (name0, ths) => fn accum => |
477 foldx (fn (name0, ths) => fn accum => |