4 Sledgehammer's machine-learning-based relevance filter (MaSh). |
4 Sledgehammer's machine-learning-based relevance filter (MaSh). |
5 *) |
5 *) |
6 |
6 |
7 signature SLEDGEHAMMER_MASH = |
7 signature SLEDGEHAMMER_MASH = |
8 sig |
8 sig |
9 type status = ATP_Problem_Generate.status |
|
10 type stature = ATP_Problem_Generate.stature |
9 type stature = ATP_Problem_Generate.stature |
11 type fact = Sledgehammer_Fact.fact |
10 type fact = Sledgehammer_Fact.fact |
12 type fact_override = Sledgehammer_Fact.fact_override |
11 type fact_override = Sledgehammer_Fact.fact_override |
13 type params = Sledgehammer_Provers.params |
12 type params = Sledgehammer_Provers.params |
14 type relevance_fudge = Sledgehammer_Provers.relevance_fudge |
13 type relevance_fudge = Sledgehammer_Provers.relevance_fudge |
31 int -> (('a * thm) list * ('a * thm) list) list -> ('a * thm) list |
30 int -> (('a * thm) list * ('a * thm) list) list -> ('a * thm) list |
32 val is_likely_tautology_or_too_meta : thm -> bool |
31 val is_likely_tautology_or_too_meta : thm -> bool |
33 val theory_ord : theory * theory -> order |
32 val theory_ord : theory * theory -> order |
34 val thm_ord : thm * thm -> order |
33 val thm_ord : thm * thm -> order |
35 val features_of : |
34 val features_of : |
36 Proof.context -> string -> theory -> status -> term list -> string list |
35 Proof.context -> string -> theory -> stature -> term list -> string list |
37 val isabelle_dependencies_of : unit Symtab.table -> thm -> string list |
36 val isabelle_dependencies_of : unit Symtab.table -> thm -> string list |
38 val goal_of_thm : theory -> thm -> thm |
37 val goal_of_thm : theory -> thm -> thm |
39 val run_prover_for_mash : |
38 val run_prover_for_mash : |
40 Proof.context -> params -> string -> fact list -> thm -> prover_result |
39 Proof.context -> params -> string -> fact list -> thm -> prover_result |
41 val mash_CLEAR : Proof.context -> unit |
40 val mash_CLEAR : Proof.context -> unit |
263 |
262 |
264 val term_max_depth = 1 |
263 val term_max_depth = 1 |
265 val type_max_depth = 1 |
264 val type_max_depth = 1 |
266 |
265 |
267 (* TODO: Generate type classes for types? *) |
266 (* TODO: Generate type classes for types? *) |
268 fun features_of ctxt prover thy status ts = |
267 fun features_of ctxt prover thy (scope, status) ts = |
269 thy_feature_name_of (Context.theory_name thy) :: |
268 thy_feature_name_of (Context.theory_name thy) :: |
270 interesting_terms_types_and_classes ctxt prover term_max_depth type_max_depth |
269 interesting_terms_types_and_classes ctxt prover term_max_depth type_max_depth |
271 ts |
270 ts |
272 |> forall is_lambda_free ts ? cons "no_lams" |
271 |> forall is_lambda_free ts ? cons "no_lams" |
273 |> forall (not o exists_Const is_exists) ts ? cons "no_skos" |
272 |> forall (not o exists_Const is_exists) ts ? cons "no_skos" |
|
273 |> scope <> Global ? cons "local" |
274 |> (case status of |
274 |> (case status of |
275 General => I |
275 General => I |
276 | Induction => cons "induction" |
276 | Induction => cons "induction" |
277 | Intro => cons "intro" |
277 | Intro => cons "intro" |
278 | Inductive => cons "inductive" |
278 | Inductive => cons "inductive" |
523 concl_t facts = |
523 concl_t facts = |
524 let |
524 let |
525 val thy = Proof_Context.theory_of ctxt |
525 val thy = Proof_Context.theory_of ctxt |
526 val fact_graph = #fact_graph (mash_get ctxt) |
526 val fact_graph = #fact_graph (mash_get ctxt) |
527 val parents = parents_wrt_facts facts fact_graph |
527 val parents = parents_wrt_facts facts fact_graph |
528 val feats = features_of ctxt prover thy General (concl_t :: hyp_ts) |
528 val feats = features_of ctxt prover thy (Local, General) (concl_t :: hyp_ts) |
529 val suggs = |
529 val suggs = |
530 if Graph.is_empty fact_graph then [] |
530 if Graph.is_empty fact_graph then [] |
531 else mash_QUERY ctxt overlord (max_suggs_of max_facts) (parents, feats) |
531 else mash_QUERY ctxt overlord (max_suggs_of max_facts) (parents, feats) |
532 val selected = facts |> suggested_facts suggs |
532 val selected = facts |> suggested_facts suggs |
533 val unknown = facts |> filter_out (is_fact_in_graph fact_graph) |
533 val unknown = facts |> filter_out (is_fact_in_graph fact_graph) |
566 launch_thread timeout |
566 launch_thread timeout |
567 (fn () => |
567 (fn () => |
568 let |
568 let |
569 val thy = Proof_Context.theory_of ctxt |
569 val thy = Proof_Context.theory_of ctxt |
570 val name = timestamp () ^ " " ^ serial_string () (* freshish *) |
570 val name = timestamp () ^ " " ^ serial_string () (* freshish *) |
571 val feats = features_of ctxt prover thy General [t] |
571 val feats = features_of ctxt prover thy (Local, General) [t] |
572 val deps = used_ths |> map nickname_of |
572 val deps = used_ths |> map nickname_of |
573 in |
573 in |
574 mash_map ctxt (fn {thys, fact_graph} => |
574 mash_map ctxt (fn {thys, fact_graph} => |
575 let |
575 let |
576 val parents = parents_wrt_facts facts fact_graph |
576 val parents = parents_wrt_facts facts fact_graph |
611 ths |> filter_out is_likely_tautology_or_too_meta |
611 ths |> filter_out is_likely_tautology_or_too_meta |
612 |> map (rpair () o nickname_of) |
612 |> map (rpair () o nickname_of) |
613 |> Symtab.make |
613 |> Symtab.make |
614 fun trim_deps deps = if length deps > max_dependencies then [] else deps |
614 fun trim_deps deps = if length deps > max_dependencies then [] else deps |
615 fun do_fact _ (accum as (_, true)) = accum |
615 fun do_fact _ (accum as (_, true)) = accum |
616 | do_fact ((_, (_, status)), th) ((parents, upds), false) = |
616 | do_fact ((_, stature), th) ((parents, upds), false) = |
617 let |
617 let |
618 val name = nickname_of th |
618 val name = nickname_of th |
619 val feats = |
619 val feats = |
620 features_of ctxt prover (theory_of_thm th) status [prop_of th] |
620 features_of ctxt prover (theory_of_thm th) stature [prop_of th] |
621 val deps = isabelle_dependencies_of all_names th |> trim_deps |
621 val deps = isabelle_dependencies_of all_names th |> trim_deps |
622 val upd = (name, parents, feats, deps) |
622 val upd = (name, parents, feats, deps) |
623 in (([name], upd :: upds), timed_out pass1_learn_timeout_factor) end |
623 in (([name], upd :: upds), timed_out pass1_learn_timeout_factor) end |
624 val parents = parents_wrt_facts facts fact_graph |
624 val parents = parents_wrt_facts facts fact_graph |
625 val ((_, upds), _) = |
625 val ((_, upds), _) = |