37 val all_names = facts |> map (Thm.get_name_hint o snd) |
37 val all_names = facts |> map (Thm.get_name_hint o snd) |
38 val iter_ok = Unsynchronized.ref 0 |
38 val iter_ok = Unsynchronized.ref 0 |
39 val mash_ok = Unsynchronized.ref 0 |
39 val mash_ok = Unsynchronized.ref 0 |
40 val mesh_ok = Unsynchronized.ref 0 |
40 val mesh_ok = Unsynchronized.ref 0 |
41 val isar_ok = Unsynchronized.ref 0 |
41 val isar_ok = Unsynchronized.ref 0 |
42 fun find_sugg facts sugg = |
42 fun sugg_facts hyp_ts concl_t suggs = |
43 find_first (fn (_, th) => Thm.get_name_hint th = sugg) facts |
43 suggested_facts suggs |
44 fun sugg_facts hyp_ts concl_t facts = |
|
45 map_filter (find_sugg facts) |
|
46 #> take (max_facts_slack * the max_facts) |
44 #> take (max_facts_slack * the max_facts) |
47 #> Sledgehammer_Fact.maybe_instantiate_inducts ctxt hyp_ts concl_t |
45 #> Sledgehammer_Fact.maybe_instantiate_inducts ctxt hyp_ts concl_t |
48 fun mesh_facts fsp = |
46 fun mesh_facts fsp = |
49 let |
47 let |
50 val (fs1, fs2) = |
48 val (fs1, fs2) = |
86 let |
84 let |
87 val facts = facts |> take (the max_facts) |
85 val facts = facts |> take (the max_facts) |
88 val res as {outcome, ...} = run_prover ctxt params facts goal |
86 val res as {outcome, ...} = run_prover ctxt params facts goal |
89 val _ = if is_none outcome then ok := !ok + 1 else () |
87 val _ = if is_none outcome then ok := !ok + 1 else () |
90 in str_of_res heading facts res end |
88 in str_of_res heading facts res end |
91 fun solve_goal j name suggs = |
89 fun solve_goal (j, line) = |
92 let |
90 let |
|
91 val (name, suggs) = extract_query line |
93 val th = |
92 val th = |
94 case find_first (fn (_, th) => Thm.get_name_hint th = name) facts of |
93 case find_first (fn (_, th) => Thm.get_name_hint th = name) facts of |
95 SOME (_, th) => th |
94 SOME (_, th) => th |
96 | NONE => error ("No fact called \"" ^ name ^ "\"") |
95 | NONE => error ("No fact called \"" ^ name ^ "\"") |
97 val isar_deps = isabelle_dependencies_of all_names th |
96 val isar_deps = isabelle_dependencies_of all_names th |
98 val goal = goal_of_thm thy th |
97 val goal = goal_of_thm thy th |
99 val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal 1 |
98 val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal 1 |
100 val facts = facts |> filter (fn (_, th') => thm_ord (th', th) = LESS) |
99 val facts = facts |> filter (fn (_, th') => thm_ord (th', th) = LESS) |
101 val isar_facts = sugg_facts hyp_ts concl_t facts isar_deps |
100 val isar_facts = facts |> sugg_facts hyp_ts concl_t isar_deps |
102 val iter_facts = |
101 val iter_facts = |
103 Sledgehammer_Filter_Iter.iterative_relevant_facts ctxt params |
102 Sledgehammer_Filter_Iter.iterative_relevant_facts ctxt params |
104 prover_name (max_facts_slack * the max_facts) NONE hyp_ts concl_t |
103 prover_name (max_facts_slack * the max_facts) NONE hyp_ts concl_t |
105 facts |
104 facts |
106 val mash_facts = sugg_facts hyp_ts concl_t facts suggs |
105 val mash_facts = facts |> sugg_facts hyp_ts concl_t suggs |
107 val mesh_facts = mesh_facts (iter_facts, mash_facts) |
106 val mesh_facts = mesh_facts (iter_facts, mash_facts) |
108 val iter_s = prove iter_ok iterN iter_facts goal |
107 val iter_s = prove iter_ok iterN iter_facts goal |
109 val mash_s = prove mash_ok mashN mash_facts goal |
108 val mash_s = prove mash_ok mashN mash_facts goal |
110 val mesh_s = prove mesh_ok meshN mesh_facts goal |
109 val mesh_s = prove mesh_ok meshN mesh_facts goal |
111 val isar_s = prove isar_ok isarN isar_facts goal |
110 val isar_s = prove isar_ok isarN isar_facts goal |
112 in |
111 in |
113 ["Goal " ^ string_of_int j ^ ": " ^ name, iter_s, mash_s, mesh_s, |
112 ["Goal " ^ string_of_int j ^ ": " ^ name, iter_s, mash_s, mesh_s, |
114 isar_s] |
113 isar_s] |
115 |> cat_lines |> tracing |
114 |> cat_lines |> tracing |
116 end |
115 end |
117 val explode_suggs = |
|
118 space_explode " " #> filter_out (curry (op =) "") #> map unescape_meta |
|
119 fun do_line (j, line) = |
|
120 case space_explode ":" line of |
|
121 [goal_name, suggs] => |
|
122 solve_goal j (unescape_meta goal_name) (explode_suggs suggs) |
|
123 | _ => () |
|
124 fun total_of heading ok n = |
116 fun total_of heading ok n = |
125 " " ^ heading ^ ": " ^ string_of_int (!ok) ^ " (" ^ |
117 " " ^ heading ^ ": " ^ string_of_int (!ok) ^ " (" ^ |
126 Real.fmt (StringCvt.FIX (SOME 1)) |
118 Real.fmt (StringCvt.FIX (SOME 1)) |
127 (100.0 * Real.fromInt (!ok) / Real.fromInt n) ^ "%)" |
119 (100.0 * Real.fromInt (!ok) / Real.fromInt n) ^ "%)" |
128 val inst_inducts = Config.get ctxt Sledgehammer_Fact.instantiate_inducts |
120 val inst_inducts = Config.get ctxt Sledgehammer_Fact.instantiate_inducts |
133 "instantiate_inducts" |> not inst_inducts ? prefix "dont_"] |
125 "instantiate_inducts" |> not inst_inducts ? prefix "dont_"] |
134 val n = length lines |
126 val n = length lines |
135 in |
127 in |
136 tracing " * * *"; |
128 tracing " * * *"; |
137 tracing ("Options: " ^ commas options); |
129 tracing ("Options: " ^ commas options); |
138 List.app do_line (tag_list 1 lines); |
130 List.app solve_goal (tag_list 1 lines); |
139 ["Successes (of " ^ string_of_int n ^ " goals)", |
131 ["Successes (of " ^ string_of_int n ^ " goals)", |
140 total_of iterN iter_ok n, |
132 total_of iterN iter_ok n, |
141 total_of mashN mash_ok n, |
133 total_of mashN mash_ok n, |
142 total_of meshN mesh_ok n, |
134 total_of meshN mesh_ok n, |
143 total_of isarN isar_ok n] |
135 total_of isarN isar_ok n] |