equal
deleted
inserted
replaced
64 val extra_feature_factor : real |
64 val extra_feature_factor : real |
65 val weight_facts_smoothly : 'a list -> ('a * real) list |
65 val weight_facts_smoothly : 'a list -> ('a * real) list |
66 val weight_facts_steeply : 'a list -> ('a * real) list |
66 val weight_facts_steeply : 'a list -> ('a * real) list |
67 val find_mash_suggestions : Proof.context -> int -> string list -> ('a * thm) list -> |
67 val find_mash_suggestions : Proof.context -> int -> string list -> ('a * thm) list -> |
68 ('a * thm) list -> ('a * thm) list -> ('a * thm) list * ('a * thm) list |
68 ('a * thm) list -> ('a * thm) list -> ('a * thm) list * ('a * thm) list |
69 val mash_suggested_facts : Proof.context -> theory -> params -> int -> term list -> term -> |
69 val mash_suggested_facts : Proof.context -> string -> params -> int -> term list -> term -> |
70 raw_fact list -> fact list * fact list |
70 raw_fact list -> fact list * fact list |
71 |
71 |
72 val mash_unlearn : unit -> unit |
72 val mash_unlearn : unit -> unit |
73 val mash_learn_proof : Proof.context -> params -> term -> ('a * thm) list -> thm list -> unit |
73 val mash_learn_proof : Proof.context -> params -> term -> ('a * thm) list -> thm list -> unit |
74 val mash_learn_facts : Proof.context -> params -> string -> int -> bool -> Time.time -> |
74 val mash_learn_facts : Proof.context -> params -> string -> int -> bool -> Time.time -> |
1143 |> fold (subtract (eq_snd Thm.eq_thm_prop)) [unknown_chained, unknown_proximate] |
1143 |> fold (subtract (eq_snd Thm.eq_thm_prop)) [unknown_chained, unknown_proximate] |
1144 in |
1144 in |
1145 (mesh_facts (eq_snd (gen_eq_thm ctxt)) max_facts mess, unknown) |
1145 (mesh_facts (eq_snd (gen_eq_thm ctxt)) max_facts mess, unknown) |
1146 end |
1146 end |
1147 |
1147 |
1148 fun mash_suggested_facts ctxt thy ({debug, ...} : params) max_suggs hyp_ts concl_t facts = |
1148 fun mash_suggested_facts ctxt thy_name ({debug, ...} : params) max_suggs hyp_ts concl_t facts = |
1149 let |
1149 let |
1150 val thy_name = Context.theory_name thy |
|
1151 val algorithm = the_mash_algorithm () |
1150 val algorithm = the_mash_algorithm () |
1152 |
1151 |
1153 val facts = facts |
1152 val facts = facts |
1154 |> rev_sort_list_prefix (crude_thm_ord ctxt o apply2 snd) |
1153 |> rev_sort_list_prefix (crude_thm_ord ctxt o apply2 snd) |
1155 (Int.max (num_extra_feature_facts, max_proximity_facts)) |
1154 (Int.max (num_extra_feature_facts, max_proximity_facts)) |
1165 |
1164 |
1166 val {access_G, xtabs = ((num_facts, fact_tab), (num_feats, feat_tab)), ffds, freqs, ...} = |
1165 val {access_G, xtabs = ((num_facts, fact_tab), (num_feats, feat_tab)), ffds, freqs, ...} = |
1167 peek_state ctxt |
1166 peek_state ctxt |
1168 |
1167 |
1169 val goal_feats0 = |
1168 val goal_feats0 = |
1170 features_of ctxt (Context.theory_name thy) (Local, General) (concl_t :: hyp_ts) |
1169 features_of ctxt thy_name (Local, General) (concl_t :: hyp_ts) |
1171 val chained_feats = chained |
1170 val chained_feats = chained |
1172 |> map (rpair 1.0) |
1171 |> map (rpair 1.0) |
1173 |> map (chained_or_extra_features_of chained_feature_factor) |
1172 |> map (chained_or_extra_features_of chained_feature_factor) |
1174 |> rpair [] |-> fold (union (eq_fst (op =))) |
1173 |> rpair [] |-> fold (union (eq_fst (op =))) |
1175 val extra_feats = facts |
1174 val extra_feats = facts |
1511 [("", map fact_of_raw_fact facts)] |
1510 [("", map fact_of_raw_fact facts)] |
1512 else if max_facts <= 0 orelse null facts then |
1511 else if max_facts <= 0 orelse null facts then |
1513 [("", [])] |
1512 [("", [])] |
1514 else |
1513 else |
1515 let |
1514 let |
1516 val thy = Proof_Context.theory_of ctxt |
1515 val thy_name = Context.theory_name (Proof_Context.theory_of ctxt) |
1517 |
1516 |
1518 fun maybe_launch_thread exact min_num_facts_to_learn = |
1517 fun maybe_launch_thread exact min_num_facts_to_learn = |
1519 if not (Async_Manager_Legacy.has_running_threads MaShN) andalso |
1518 if not (Async_Manager_Legacy.has_running_threads MaShN) andalso |
1520 Time.toSeconds timeout >= min_secs_for_learning then |
1519 Time.toSeconds timeout >= min_secs_for_learning then |
1521 let val timeout = time_mult learn_timeout_slack timeout in |
1520 let val timeout = time_mult learn_timeout_slack timeout in |
1574 fun mepo () = |
1573 fun mepo () = |
1575 (mepo_suggested_facts ctxt params max_facts NONE hyp_ts concl_t unique_facts |
1574 (mepo_suggested_facts ctxt params max_facts NONE hyp_ts concl_t unique_facts |
1576 |> weight_facts_steeply, []) |
1575 |> weight_facts_steeply, []) |
1577 |
1576 |
1578 fun mash () = |
1577 fun mash () = |
1579 mash_suggested_facts ctxt thy params (generous_max_suggestions max_facts) hyp_ts concl_t |
1578 mash_suggested_facts ctxt thy_name params |
1580 facts |
1579 (generous_max_suggestions max_facts) hyp_ts concl_t facts |
1581 |>> weight_facts_steeply |
1580 |>> weight_facts_steeply |
1582 |
1581 |
1583 val mess = |
1582 val mess = |
1584 (* the order is important for the "case" expression below *) |
1583 (* the order is important for the "case" expression below *) |
1585 [] |> effective_fact_filter <> mepoN ? cons (mash_weight, mash) |
1584 [] |> effective_fact_filter <> mepoN ? cons (mash_weight, mash) |