57 val mash_unlearn : Proof.context -> unit |
57 val mash_unlearn : Proof.context -> unit |
58 val mash_could_suggest_facts : unit -> bool |
58 val mash_could_suggest_facts : unit -> bool |
59 val mash_can_suggest_facts : Proof.context -> bool |
59 val mash_can_suggest_facts : Proof.context -> bool |
60 val mash_suggested_facts : |
60 val mash_suggested_facts : |
61 Proof.context -> params -> string -> int -> term list -> term |
61 Proof.context -> params -> string -> int -> term list -> term |
62 -> ('a * thm) list -> (('a * thm) * real) list * ('a * thm) list |
62 -> fact list -> (fact * real) list * fact list |
63 val mash_learn_proof : |
63 val mash_learn_proof : |
64 Proof.context -> params -> string -> term -> ('a * thm) list -> thm list |
64 Proof.context -> params -> string -> term -> ('a * thm) list -> thm list |
65 -> unit |
65 -> unit |
66 val mash_learn : |
66 val mash_learn : |
67 Proof.context -> params -> fact_override -> thm list -> bool -> unit |
67 Proof.context -> params -> fact_override -> thm list -> bool -> unit |
604 fun max_suggs_of max_facts = max_facts + Int.min (50, max_facts) |
604 fun max_suggs_of max_facts = max_facts + Int.min (50, max_facts) |
605 |
605 |
606 fun is_fact_in_graph fact_G (_, th) = |
606 fun is_fact_in_graph fact_G (_, th) = |
607 can (Graph.get_node fact_G) (nickname_of th) |
607 can (Graph.get_node fact_G) (nickname_of th) |
608 |
608 |
|
609 fun interleave [] ys = ys |
|
610 | interleave xs [] = xs |
|
611 | interleave (x :: xs) (y :: ys) = x :: y :: interleave xs ys |
|
612 |
609 fun mash_suggested_facts ctxt ({overlord, ...} : params) prover max_facts hyp_ts |
613 fun mash_suggested_facts ctxt ({overlord, ...} : params) prover max_facts hyp_ts |
610 concl_t facts = |
614 concl_t facts = |
611 let |
615 let |
612 val thy = Proof_Context.theory_of ctxt |
616 val thy = Proof_Context.theory_of ctxt |
613 val (fact_G, suggs) = |
617 val (fact_G, suggs) = |
621 features_of ctxt prover thy (Local, General) (concl_t :: hyp_ts) |
625 features_of ctxt prover thy (Local, General) (concl_t :: hyp_ts) |
622 in |
626 in |
623 (fact_G, mash_QUERY ctxt overlord (max_suggs_of max_facts) |
627 (fact_G, mash_QUERY ctxt overlord (max_suggs_of max_facts) |
624 (parents, feats)) |
628 (parents, feats)) |
625 end) |
629 end) |
626 val selected = |
630 val sels = |
627 facts |> suggested_facts suggs |
631 facts |> suggested_facts suggs |
628 (* The weights currently returned by "mash.py" are too extreme to |
632 (* The weights currently returned by "mash.py" are too extreme to |
629 make any sense. *) |
633 make any sense. *) |
630 |> map fst |> weight_mepo_facts |
634 |> map fst |
631 val unknown = facts |> filter_out (is_fact_in_graph fact_G) |
635 val (unk_global, unk_local) = |
632 in (selected, unknown) end |
636 facts |> filter_out (is_fact_in_graph fact_G) |
|
637 |> List.partition (fn ((_, (loc, _)), _) => loc = Global) |
|
638 in (interleave unk_local sels |> weight_mepo_facts, unk_global) end |
633 |
639 |
634 fun add_to_fact_graph ctxt (name, parents, feats, deps) (adds, graph) = |
640 fun add_to_fact_graph ctxt (name, parents, feats, deps) (adds, graph) = |
635 let |
641 let |
636 fun maybe_add_from from (accum as (parents, graph)) = |
642 fun maybe_add_from from (accum as (parents, graph)) = |
637 try_graph ctxt "updating graph" accum (fn () => |
643 try_graph ctxt "updating graph" accum (fn () => |