55 find_first (fn (_, th) => Thm.get_name_hint th = sugg) facts |
55 find_first (fn (_, th) => Thm.get_name_hint th = sugg) facts |
56 fun sugg_facts hyp_ts concl_t facts = |
56 fun sugg_facts hyp_ts concl_t facts = |
57 map_filter (find_sugg facts o of_fact_name) |
57 map_filter (find_sugg facts o of_fact_name) |
58 #> take (max_relevant_slack * the max_relevant) |
58 #> take (max_relevant_slack * the max_relevant) |
59 #> Sledgehammer_Fact.maybe_instantiate_inducts ctxt hyp_ts concl_t |
59 #> Sledgehammer_Fact.maybe_instantiate_inducts ctxt hyp_ts concl_t |
60 #> map (apfst (apfst (fn name => name ()))) |
60 fun hybrid_facts fsp = |
61 fun iter_mash_facts fs1 fs2 = |
|
62 let |
61 let |
|
62 val (fs1, fs2) = |
|
63 fsp |> pairself (map (apfst (apfst (fn name => name ())))) |
63 val fact_eq = (op =) o pairself fst |
64 val fact_eq = (op =) o pairself fst |
64 fun score_in f fs = |
65 fun score_in f fs = |
65 case find_index (curry fact_eq f) fs of |
66 case find_index (curry fact_eq f) fs of |
66 ~1 => length fs |
67 ~1 => length fs |
67 | j => j |
68 | j => j |
68 fun score_of f = score_in f fs1 + score_in f fs2 |
69 fun score_of f = score_in f fs1 + score_in f fs2 |
69 in |
70 in |
70 union fact_eq fs1 fs2 |
71 union fact_eq fs1 fs2 |
71 |> map (`score_of) |> sort (int_ord o pairself fst) |> map snd |
72 |> map (`score_of) |> sort (int_ord o pairself fst) |> map snd |
72 |> take (the max_relevant) |
73 |> take (the max_relevant) |
|
74 |> map (apfst (apfst K)) |
73 end |
75 end |
74 fun with_index facts s = |
76 fun with_index facts s = (find_index (curry (op =) s) facts + 1, s) |
75 (find_index (fn ((s', _), _) => s = s') facts + 1, s) |
|
76 fun index_string (j, s) = s ^ "@" ^ string_of_int j |
77 fun index_string (j, s) = s ^ "@" ^ string_of_int j |
77 fun str_of_res label facts {outcome, run_time, used_facts, ...} = |
78 fun str_of_res label facts {outcome, run_time, used_facts, ...} = |
78 " " ^ label ^ ": " ^ |
79 let val facts = facts |> map (fn ((name, _), _) => name ()) in |
79 (if is_none outcome then |
80 " " ^ label ^ ": " ^ |
80 "Success (" ^ ATP_Util.string_from_time run_time ^ "): " ^ |
81 (if is_none outcome then |
81 (used_facts |> map (with_index facts o fst) |
82 "Success (" ^ ATP_Util.string_from_time run_time ^ "): " ^ |
82 |> sort (int_ord o pairself fst) |
83 (used_facts |> map (with_index facts o fst) |
83 |> map index_string |
84 |> sort (int_ord o pairself fst) |
84 |> space_implode " ") ^ |
85 |> map index_string |
85 (if length facts < the max_relevant then |
86 |> space_implode " ") ^ |
86 " (of " ^ string_of_int (length facts) ^ ")" |
87 (if length facts < the max_relevant then |
87 else |
88 " (of " ^ string_of_int (length facts) ^ ")" |
88 "") |
89 else |
89 else |
90 "") |
90 "Failure: " ^ |
91 else |
91 (facts |> map (fst o fst) |
92 "Failure: " ^ |
92 |> take (the max_relevant) |
93 (facts |> take (the max_relevant) |
93 |> tag_list 1 |
94 |> tag_list 1 |
94 |> map index_string |
95 |> map index_string |
95 |> space_implode " ")) |
96 |> space_implode " ")) |
|
97 end |
96 fun prove ok heading facts goal = |
98 fun prove ok heading facts goal = |
97 let |
99 let |
98 val facts = facts |> take (the max_relevant) |
100 val facts = facts |> take (the max_relevant) |
99 val res as {outcome, ...} = run_prover ctxt params facts goal |
101 val res as {outcome, ...} = run_prover ctxt params facts goal |
100 val _ = if is_none outcome then ok := !ok + 1 else () |
102 val _ = if is_none outcome then ok := !ok + 1 else () |
113 val isa_facts = sugg_facts hyp_ts concl_t facts isa_deps |
115 val isa_facts = sugg_facts hyp_ts concl_t facts isa_deps |
114 val iter_facts = |
116 val iter_facts = |
115 iter_facts ctxt params (max_relevant_slack * the max_relevant) goal |
117 iter_facts ctxt params (max_relevant_slack * the max_relevant) goal |
116 facts |
118 facts |
117 val mash_facts = sugg_facts hyp_ts concl_t facts suggs |
119 val mash_facts = sugg_facts hyp_ts concl_t facts suggs |
118 val iter_mash_facts = iter_mash_facts iter_facts mash_facts |
120 val iter_mash_facts = hybrid_facts (iter_facts, mash_facts) |
119 val iter_s = prove iter_ok iterN iter_facts goal |
121 val iter_s = prove iter_ok iterN iter_facts goal |
120 val mash_s = prove mash_ok mashN mash_facts goal |
122 val mash_s = prove mash_ok mashN mash_facts goal |
121 val iter_mash_s = prove iter_mash_ok iter_mashN iter_mash_facts goal |
123 val iter_mash_s = prove iter_mash_ok iter_mashN iter_mash_facts goal |
122 val isa_s = prove isa_ok isaN isa_facts goal |
124 val isa_s = prove isa_ok isaN isa_facts goal |
123 in |
125 in |