14 type one_line_params = Sledgehammer_Reconstructor.one_line_params |
14 type one_line_params = Sledgehammer_Reconstructor.one_line_params |
15 |
15 |
16 val trace : bool Config.T |
16 val trace : bool Config.T |
17 |
17 |
18 type isar_params = |
18 type isar_params = |
19 bool * (string option * string option) * Time.time * real * bool |
19 bool * (string option * string option) * Time.time * real * bool * bool |
20 * (term, string) atp_step list * thm |
20 * (term, string) atp_step list * thm |
21 |
21 |
22 val proof_text : Proof.context -> bool -> bool option -> (unit -> isar_params) -> int -> |
22 val proof_text : Proof.context -> bool -> bool option -> (unit -> isar_params) -> int -> |
23 one_line_params -> string |
23 one_line_params -> string |
24 end; |
24 end; |
33 open Sledgehammer_Util |
33 open Sledgehammer_Util |
34 open Sledgehammer_Reconstructor |
34 open Sledgehammer_Reconstructor |
35 open Sledgehammer_Isar_Proof |
35 open Sledgehammer_Isar_Proof |
36 open Sledgehammer_Isar_Preplay |
36 open Sledgehammer_Isar_Preplay |
37 open Sledgehammer_Isar_Compress |
37 open Sledgehammer_Isar_Compress |
38 open Sledgehammer_Isar_Try0 |
|
39 open Sledgehammer_Isar_Minimize |
38 open Sledgehammer_Isar_Minimize |
40 |
39 |
41 structure String_Redirect = ATP_Proof_Redirect( |
40 structure String_Redirect = ATP_Proof_Redirect( |
42 type key = atp_step_name |
41 type key = atp_step_name |
43 val ord = fn ((s, _ : string list), (s', _)) => fast_string_ord (s, s') |
42 val ord = fn ((s, _ : string list), (s', _)) => fast_string_ord (s, s') |
107 else |
106 else |
108 add_lines_pass2 res (map (replace_dependencies_in_line (name, deps)) lines) |
107 add_lines_pass2 res (map (replace_dependencies_in_line (name, deps)) lines) |
109 end |
108 end |
110 |
109 |
111 type isar_params = |
110 type isar_params = |
112 bool * (string option * string option) * Time.time * real * bool * (term, string) atp_step list |
111 bool * (string option * string option) * Time.time * real * bool * bool |
113 * thm |
112 * (term, string) atp_step list * thm |
114 |
113 |
115 val arith_methods = |
114 val arith_methods = |
116 [Arith_Method, Simp_Method, Auto_Method, Fastforce_Method, Blast_Method, Force_Method, |
115 [Arith_Method, Simp_Method, Auto_Method, Fastforce_Method, Blast_Method, Force_Method, |
117 Algebra_Method, Metis_Method (NONE, NONE), Meson_Method] |
116 Algebra_Method, Metis_Method (NONE, NONE), Meson_Method] |
118 val datatype_methods = [Simp_Method, Simp_Size_Method] |
117 val datatype_methods = [Simp_Method, Simp_Size_Method] |
127 fun isar_proof_text ctxt debug isar_proofs isar_params |
126 fun isar_proof_text ctxt debug isar_proofs isar_params |
128 (one_line_params as (_, _, _, _, subgoal, subgoal_count)) = |
127 (one_line_params as (_, _, _, _, subgoal, subgoal_count)) = |
129 let |
128 let |
130 fun isar_proof_of () = |
129 fun isar_proof_of () = |
131 let |
130 let |
132 val SOME (verbose, alt_metis_args, preplay_timeout, compress_isar, try0_isar, atp_proof, |
131 val SOME (verbose, alt_metis_args, preplay_timeout, compress_isar, try0_isar, minimize, |
133 goal) = try isar_params () |
132 atp_proof, goal) = try isar_params () |
134 |
133 |
135 val metislike_methods = insert (op =) (Metis_Method alt_metis_args) metislike_methods0 |
134 val metislike_methods = insert (op =) (Metis_Method alt_metis_args) metislike_methods0 |
136 |
135 |
137 val (params, _, concl_t) = strip_subgoal goal subgoal ctxt |
136 val (params, _, concl_t) = strip_subgoal goal subgoal ctxt |
138 val fixes = map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params |
137 val fixes = map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params |
139 val ctxt = ctxt |> Variable.set_body false |> Proof_Context.add_fixes fixes |> snd |
138 val ctxt = ctxt |> Variable.set_body false |> Proof_Context.add_fixes fixes |> snd |
140 |
139 |
141 val do_preplay = preplay_timeout <> Time.zeroTime |
140 val do_preplay = preplay_timeout <> Time.zeroTime |
142 val try0_isar = try0_isar andalso do_preplay |
|
143 val compress_isar = if isar_proofs = NONE andalso do_preplay then 1000.0 else compress_isar |
141 val compress_isar = if isar_proofs = NONE andalso do_preplay then 1000.0 else compress_isar |
144 |
142 |
145 val is_fixed = Variable.is_declared ctxt orf can Name.dest_skolem |
143 val is_fixed = Variable.is_declared ctxt orf can Name.dest_skolem |
146 fun skolems_of t = Term.add_frees t [] |> filter_out (is_fixed o fst) |> rev |
144 fun skolems_of t = Term.add_frees t [] |> filter_out (is_fixed o fst) |> rev |
147 |
145 |
309 val (play_outcome, isar_proof) = |
307 val (play_outcome, isar_proof) = |
310 canonical_isar_proof |
308 canonical_isar_proof |
311 |> tap (trace_isar_proof "Original") |
309 |> tap (trace_isar_proof "Original") |
312 |> compress_isar_proof ctxt compress_isar preplay_data |
310 |> compress_isar_proof ctxt compress_isar preplay_data |
313 |> tap (trace_isar_proof "Compressed") |
311 |> tap (trace_isar_proof "Compressed") |
314 |> try0_isar ? try0_isar_proof ctxt preplay_timeout preplay_data |
|
315 |> tap (trace_isar_proof "Tried0") |
312 |> tap (trace_isar_proof "Tried0") |
316 |> postprocess_isar_proof_remove_unreferenced_steps |
313 |> postprocess_isar_proof_remove_unreferenced_steps |
317 (keep_fastest_method_of_isar_step (!preplay_data) |
314 (keep_fastest_method_of_isar_step (!preplay_data) |
318 #> try0_isar(*### minimize*) ? minimize_isar_step_dependencies ctxt preplay_data) |
315 #> minimize ? minimize_isar_step_dependencies ctxt preplay_data) |
319 |> tap (trace_isar_proof "Minimized") |
316 |> tap (trace_isar_proof "Minimized") |
320 |> `(preplay_outcome_of_isar_proof (!preplay_data)) |
317 |> `(preplay_outcome_of_isar_proof (!preplay_data)) |
321 ||> chain_isar_proof |
318 ||> chain_isar_proof |
322 ||> kill_useless_labels_in_isar_proof |
319 ||> kill_useless_labels_in_isar_proof |
323 ||> relabel_isar_proof_finally |
320 ||> relabel_isar_proof_finally |