9 signature SLEDGEHAMMER_PROVERS = |
9 signature SLEDGEHAMMER_PROVERS = |
10 sig |
10 sig |
11 type failure = ATP_Proof.failure |
11 type failure = ATP_Proof.failure |
12 type stature = ATP_Problem_Generate.stature |
12 type stature = ATP_Problem_Generate.stature |
13 type type_enc = ATP_Problem_Generate.type_enc |
13 type type_enc = ATP_Problem_Generate.type_enc |
|
14 type fact = Sledgehammer_Fact.fact |
14 type reconstructor = Sledgehammer_Reconstruct.reconstructor |
15 type reconstructor = Sledgehammer_Reconstruct.reconstructor |
15 type play = Sledgehammer_Reconstruct.play |
16 type play = Sledgehammer_Reconstruct.play |
16 type minimize_command = Sledgehammer_Reconstruct.minimize_command |
17 type minimize_command = Sledgehammer_Reconstruct.minimize_command |
17 |
18 |
18 datatype mode = Auto_Try | Try | Normal | MaSh | Auto_Minimize | Minimize |
19 datatype mode = Auto_Try | Try | Normal | MaSh | Auto_Minimize | Minimize |
60 max_imperfect : real, |
61 max_imperfect : real, |
61 max_imperfect_exp : real, |
62 max_imperfect_exp : real, |
62 threshold_divisor : real, |
63 threshold_divisor : real, |
63 ridiculous_threshold : real} |
64 ridiculous_threshold : real} |
64 |
65 |
65 datatype prover_fact = |
|
66 Untranslated_Fact of (string * stature) * thm | |
|
67 SMT_Weighted_Fact of (string * stature) * (int option * thm) |
|
68 |
|
69 type prover_problem = |
66 type prover_problem = |
70 {state : Proof.state, |
67 {state : Proof.state, |
71 goal : thm, |
68 goal : thm, |
72 subgoal : int, |
69 subgoal : int, |
73 subgoal_count : int, |
70 subgoal_count : int, |
74 facts : prover_fact list} |
71 facts : fact list} |
75 |
72 |
76 type prover_result = |
73 type prover_result = |
77 {outcome : failure option, |
74 {outcome : failure option, |
78 used_facts : (string * stature) list, |
75 used_facts : (string * stature) list, |
79 run_time : Time.time, |
76 run_time : Time.time, |
121 val smt_relevance_fudge : relevance_fudge |
118 val smt_relevance_fudge : relevance_fudge |
122 val relevance_fudge_for_prover : Proof.context -> string -> relevance_fudge |
119 val relevance_fudge_for_prover : Proof.context -> string -> relevance_fudge |
123 val weight_smt_fact : |
120 val weight_smt_fact : |
124 Proof.context -> int -> ((string * stature) * thm) * int |
121 Proof.context -> int -> ((string * stature) * thm) * int |
125 -> (string * stature) * (int option * thm) |
122 -> (string * stature) * (int option * thm) |
126 val untranslated_fact : prover_fact -> (string * stature) * thm |
|
127 val smt_weighted_fact : |
|
128 Proof.context -> int -> prover_fact * int |
|
129 -> (string * stature) * (int option * thm) |
|
130 val supported_provers : Proof.context -> unit |
123 val supported_provers : Proof.context -> unit |
131 val kill_provers : unit -> unit |
124 val kill_provers : unit -> unit |
132 val running_provers : unit -> unit |
125 val running_provers : unit -> unit |
133 val messages : int option -> unit |
126 val messages : int option -> unit |
134 val is_fact_chained : (('a * stature) * 'b) -> bool |
127 val is_fact_chained : (('a * stature) * 'b) -> bool |
147 open ATP_Systems |
140 open ATP_Systems |
148 open ATP_Problem_Generate |
141 open ATP_Problem_Generate |
149 open ATP_Proof_Reconstruct |
142 open ATP_Proof_Reconstruct |
150 open Metis_Tactic |
143 open Metis_Tactic |
151 open Sledgehammer_Util |
144 open Sledgehammer_Util |
|
145 open Sledgehammer_Fact |
152 open Sledgehammer_Reconstruct |
146 open Sledgehammer_Reconstruct |
153 |
147 |
154 |
148 |
155 (** The Sledgehammer **) |
149 (** The Sledgehammer **) |
156 |
150 |
353 max_imperfect : real, |
347 max_imperfect : real, |
354 max_imperfect_exp : real, |
348 max_imperfect_exp : real, |
355 threshold_divisor : real, |
349 threshold_divisor : real, |
356 ridiculous_threshold : real} |
350 ridiculous_threshold : real} |
357 |
351 |
358 datatype prover_fact = |
|
359 Untranslated_Fact of (string * stature) * thm | |
|
360 SMT_Weighted_Fact of (string * stature) * (int option * thm) |
|
361 |
|
362 type prover_problem = |
352 type prover_problem = |
363 {state : Proof.state, |
353 {state : Proof.state, |
364 goal : thm, |
354 goal : thm, |
365 subgoal : int, |
355 subgoal : int, |
366 subgoal_count : int, |
356 subgoal_count : int, |
367 facts : prover_fact list} |
357 facts : fact list} |
368 |
358 |
369 type prover_result = |
359 type prover_result = |
370 {outcome : failure option, |
360 {outcome : failure option, |
371 used_facts : (string * stature) list, |
361 used_facts : (string * stature) list, |
372 run_time : Time.time, |
362 run_time : Time.time, |
427 |
417 |
428 fun weight_smt_fact ctxt num_facts ((info, th), j) = |
418 fun weight_smt_fact ctxt num_facts ((info, th), j) = |
429 let val thy = Proof_Context.theory_of ctxt in |
419 let val thy = Proof_Context.theory_of ctxt in |
430 (info, (smt_fact_weight ctxt j num_facts, th |> Thm.transfer thy)) |
420 (info, (smt_fact_weight ctxt j num_facts, th |> Thm.transfer thy)) |
431 end |
421 end |
432 |
|
433 fun untranslated_fact (Untranslated_Fact p) = p |
|
434 | untranslated_fact (SMT_Weighted_Fact (info, (_, th))) = (info, th) |
|
435 fun smt_weighted_fact _ _ (SMT_Weighted_Fact p, _) = p |
|
436 | smt_weighted_fact ctxt num_facts (fact, j) = |
|
437 (untranslated_fact fact, j) |> weight_smt_fact ctxt num_facts |
|
438 |
422 |
439 fun overlord_file_location_for_prover prover = |
423 fun overlord_file_location_for_prover prover = |
440 (getenv "ISABELLE_HOME_USER", "prob_" ^ prover) |
424 (getenv "ISABELLE_HOME_USER", "prob_" ^ prover) |
441 |
425 |
442 fun proof_banner mode name = |
426 fun proof_banner mode name = |
771 val value as (atp_problem, _, fact_names, _, _) = |
755 val value as (atp_problem, _, fact_names, _, _) = |
772 if cache_key = SOME key then |
756 if cache_key = SOME key then |
773 cache_value |
757 cache_value |
774 else |
758 else |
775 facts |
759 facts |
776 |> map untranslated_fact |
|
777 |> not sound |
760 |> not sound |
778 ? filter_out (is_dangerous_prop ctxt o prop_of o snd) |
761 ? filter_out (is_dangerous_prop ctxt o prop_of o snd) |
779 |> take num_facts |
762 |> take num_facts |
780 |> not (is_type_enc_polymorphic type_enc) ? monomorphize_facts |
763 |> not (is_type_enc_polymorphic type_enc) ? monomorphize_facts |
781 |> map (apsnd prop_of) |
764 |> map (apsnd prop_of) |
1077 minimize_command |
1059 minimize_command |
1078 ({state, goal, subgoal, subgoal_count, facts, ...} : prover_problem) = |
1060 ({state, goal, subgoal, subgoal_count, facts, ...} : prover_problem) = |
1079 let |
1061 let |
1080 val ctxt = Proof.context_of state |
1062 val ctxt = Proof.context_of state |
1081 val num_facts = length facts |
1063 val num_facts = length facts |
1082 val facts = facts ~~ (0 upto num_facts - 1) |
1064 val facts = |
1083 |> map (smt_weighted_fact ctxt num_facts) |
1065 facts ~~ (0 upto num_facts - 1) |
|
1066 |> map (weight_smt_fact ctxt num_facts) |
1084 val {outcome, used_facts = used_pairs, run_time} = |
1067 val {outcome, used_facts = used_pairs, run_time} = |
1085 smt_filter_loop name params state goal subgoal facts |
1068 smt_filter_loop name params state goal subgoal facts |
1086 val used_facts = used_pairs |> map fst |
1069 val used_facts = used_pairs |> map fst |
1087 val outcome = outcome |> Option.map failure_from_smt_failure |
1070 val outcome = outcome |> Option.map failure_from_smt_failure |
1088 val (preplay, message, message_tail) = |
1071 val (preplay, message, message_tail) = |
1124 lam_trans |> the_default metis_default_lam_trans) |
1107 lam_trans |> the_default metis_default_lam_trans) |
1125 else if name = smtN then |
1108 else if name = smtN then |
1126 SMT |
1109 SMT |
1127 else |
1110 else |
1128 raise Fail ("unknown reconstructor: " ^ quote name) |
1111 raise Fail ("unknown reconstructor: " ^ quote name) |
1129 val used_pairs = facts |> map untranslated_fact |
1112 val used_facts = facts |> map fst |
1130 val used_facts = used_pairs |> map fst |
|
1131 in |
1113 in |
1132 case play_one_line_proof (if mode = Minimize then Normal else mode) debug |
1114 case play_one_line_proof (if mode = Minimize then Normal else mode) debug |
1133 verbose timeout used_pairs state subgoal reconstr |
1115 verbose timeout facts state subgoal reconstr |
1134 [reconstr] of |
1116 [reconstr] of |
1135 play as Played (_, time) => |
1117 play as Played (_, time) => |
1136 {outcome = NONE, used_facts = used_facts, run_time = time, |
1118 {outcome = NONE, used_facts = used_facts, run_time = time, |
1137 preplay = Lazy.value play, |
1119 preplay = Lazy.value play, |
1138 message = |
1120 message = |