32 open Sledgehammer_Reconstructor |
32 open Sledgehammer_Reconstructor |
33 open Sledgehammer_Proof |
33 open Sledgehammer_Proof |
34 |
34 |
35 val trace = Attrib.setup_config_bool @{binding sledgehammer_preplay_trace} (K false) |
35 val trace = Attrib.setup_config_bool @{binding sledgehammer_preplay_trace} (K false) |
36 |
36 |
37 fun preplay_trace ctxt assms concl result = |
37 fun preplay_trace ctxt assmsp concl result = |
38 let |
38 let |
39 val ctxt = ctxt |> Config.put show_markup true |
39 val ctxt = ctxt |> Config.put show_markup true |
|
40 val assms = op @ assmsp |
40 val time = "[" ^ string_of_play_outcome result ^ "]" |> Pretty.str |
41 val time = "[" ^ string_of_play_outcome result ^ "]" |> Pretty.str |
41 val nr_of_assms = length assms |
42 val nr_of_assms = length assms |
42 val assms = assms |
43 val assms = assms |
43 |> map (Display.pretty_thm ctxt) |
44 |> map (Display.pretty_thm ctxt) |
44 |> (fn [] => Pretty.str "" |
45 |> (fn [] => Pretty.str "" |
62 end |
63 end |
63 |
64 |
64 fun resolve_fact_names ctxt names = |
65 fun resolve_fact_names ctxt names = |
65 (names |
66 (names |
66 |>> map string_of_label |
67 |>> map string_of_label |
67 |> op @ |
68 |> pairself (maps (thms_of_name ctxt))) |
68 |> maps (thms_of_name ctxt)) |
|
69 handle ERROR msg => error ("preplay error: " ^ msg) |
69 handle ERROR msg => error ("preplay error: " ^ msg) |
70 |
70 |
71 fun thm_of_proof ctxt (Proof (fixed_frees, assms, steps)) = |
71 fun thm_of_proof ctxt (Proof (fixed_frees, assms, steps)) = |
72 let |
72 let |
73 val thy = Proof_Context.theory_of ctxt |
73 val thy = Proof_Context.theory_of ctxt |
84 Logic.list_implies (assms |> map snd, concl) |
84 Logic.list_implies (assms |> map snd, concl) |
85 |> subst_free subst |
85 |> subst_free subst |
86 |> Skip_Proof.make_thm thy |
86 |> Skip_Proof.make_thm thy |
87 end |
87 end |
88 |
88 |
89 fun tac_of_method meth type_enc lam_trans ctxt facts = |
89 fun tac_of_method meth type_enc lam_trans ctxt (local_facts, global_facts) = |
|
90 Method.insert_tac local_facts THEN' |
90 (case meth of |
91 (case meth of |
91 Metis_Method_with_Args => Metis_Tactic.metis_tac [type_enc] lam_trans ctxt facts |
92 Meson_Method => Meson.meson_tac ctxt global_facts |
92 | Meson_Method => Meson.meson_tac ctxt facts |
93 | Metis_Method => Metis_Tactic.metis_tac [type_enc] lam_trans ctxt global_facts |
93 | _ => |
94 | _ => |
94 Method.insert_tac facts THEN' |
95 Method.insert_tac global_facts THEN' |
95 (case meth of |
96 (case meth of |
96 Metis_Method => Metis_Tactic.metis_tac [type_enc] lam_trans ctxt [] |
97 Simp_Method => Simplifier.asm_full_simp_tac ctxt |
97 | Simp_Method => Simplifier.asm_full_simp_tac ctxt |
|
98 | Simp_Size_Method => |
98 | Simp_Size_Method => |
99 Simplifier.asm_full_simp_tac (Simplifier.add_simp @{thm size_ne_size_imp_ne} ctxt) |
99 Simplifier.asm_full_simp_tac (Simplifier.add_simp @{thm size_ne_size_imp_ne} ctxt) |
100 | Auto_Method => K (Clasimp.auto_tac ctxt) |
100 | Auto_Method => K (Clasimp.auto_tac ctxt) |
101 | Fastforce_Method => Clasimp.fast_force_tac ctxt |
101 | Fastforce_Method => Clasimp.fast_force_tac ctxt |
102 | Force_Method => Clasimp.force_tac ctxt |
102 | Force_Method => Clasimp.force_tac ctxt |
126 in |
126 in |
127 (* !!thesis. (!!x1..xn. t ==> thesis) ==> thesis *) |
127 (* !!thesis. (!!x1..xn. t ==> thesis) ==> thesis *) |
128 Logic.all thesis (Logic.mk_implies (inner_prop, thesis_prop)) |
128 Logic.all thesis (Logic.mk_implies (inner_prop, thesis_prop)) |
129 end) |
129 end) |
130 |
130 |
131 val facts = map (thm_of_proof ctxt) subproofs @ resolve_fact_names ctxt fact_names |
131 val facts = |
|
132 resolve_fact_names ctxt fact_names |
|
133 |>> append (map (thm_of_proof ctxt) subproofs) |
|
134 |
132 val ctxt' = ctxt |> silence_reconstructors debug |
135 val ctxt' = ctxt |> silence_reconstructors debug |
133 |
136 |
134 fun prove () = |
137 fun prove () = |
135 Goal.prove ctxt' [] [] goal (fn {context = ctxt, ...} => |
138 Goal.prove ctxt' [] [] goal (fn {context = ctxt, ...} => |
136 HEADGOAL (tac_of_method meth type_enc lam_trans ctxt facts)) |
139 HEADGOAL (tac_of_method meth type_enc lam_trans ctxt facts)) |