175 fun is_induction_fact (Untranslated_Fact ((_, (_, Induction)), _)) = true |
175 fun is_induction_fact (Untranslated_Fact ((_, (_, Induction)), _)) = true |
176 | is_induction_fact _ = false |
176 | is_induction_fact _ = false |
177 |
177 |
178 fun launch_prover (params as {debug, verbose, blocking, max_relevant, slice, |
178 fun launch_prover (params as {debug, verbose, blocking, max_relevant, slice, |
179 timeout, expect, ...}) |
179 timeout, expect, ...}) |
180 mode minimize_command only |
180 mode minimize_command only {state, goal, subgoal, subgoal_count, facts} |
181 {state, goal, subgoal, subgoal_count, facts, smt_filter} name = |
181 name = |
182 let |
182 let |
183 val ctxt = Proof.context_of state |
183 val ctxt = Proof.context_of state |
184 val hard_timeout = Time.+ (timeout, timeout) |
184 val hard_timeout = Time.+ (timeout, timeout) |
185 val birth_time = Time.now () |
185 val birth_time = Time.now () |
186 val death_time = Time.+ (birth_time, hard_timeout) |
186 val death_time = Time.+ (birth_time, hard_timeout) |
195 val filter_induction = filter_out is_induction_fact |
195 val filter_induction = filter_out is_induction_fact |
196 in {state = state, goal = goal, subgoal = subgoal, |
196 in {state = state, goal = goal, subgoal = subgoal, |
197 subgoal_count = subgoal_count, facts = |
197 subgoal_count = subgoal_count, facts = |
198 ((Sledgehammer_Provers.is_ho_atp ctxt name |> not) ? filter_induction) |
198 ((Sledgehammer_Provers.is_ho_atp ctxt name |> not) ? filter_induction) |
199 facts |
199 facts |
200 |> take num_facts, |
200 |> take num_facts} |
201 smt_filter = smt_filter} |
|
202 end |
201 end |
203 fun really_go () = |
202 fun really_go () = |
204 problem |
203 problem |
205 |> get_minimizing_prover ctxt mode name params minimize_command |
204 |> get_minimizing_prover ctxt mode name params minimize_command |
206 |> (fn {outcome, preplay, message, message_tail, ...} => |
205 |> (fn {outcome, preplay, message, message_tail, ...} => |
266 |
265 |
267 fun class_of_smt_solver ctxt name = |
266 fun class_of_smt_solver ctxt name = |
268 ctxt |> select_smt_solver name |
267 ctxt |> select_smt_solver name |
269 |> SMT_Config.solver_class_of |> SMT_Utils.string_of_class |
268 |> SMT_Config.solver_class_of |> SMT_Utils.string_of_class |
270 |
269 |
271 fun dest_SMT_Weighted_Fact (SMT_Weighted_Fact p) = p |
|
272 | dest_SMT_Weighted_Fact _ = raise Fail "dest_SMT_Weighted_Fact" |
|
273 |
|
274 val auto_try_max_relevant_divisor = 2 (* FUDGE *) |
270 val auto_try_max_relevant_divisor = 2 (* FUDGE *) |
275 |
271 |
276 fun run_sledgehammer (params as {debug, verbose, blocking, provers, |
272 fun run_sledgehammer (params as {debug, verbose, blocking, provers, |
277 relevance_thresholds, max_relevant, slice, |
273 relevance_thresholds, max_relevant, slice, |
278 timeout, ...}) |
274 ...}) |
279 mode i (relevance_override as {only, ...}) minimize_command state = |
275 mode i (relevance_override as {only, ...}) minimize_command state = |
280 if null provers then |
276 if null provers then |
281 error "No prover is set." |
277 error "No prover is set." |
282 else case subgoal_count state of |
278 else case subgoal_count state of |
283 0 => (Output.urgent_message "No subgoal!"; (false, (noneN, state))) |
279 0 => (Output.urgent_message "No subgoal!"; (false, (noneN, state))) |
301 | NONE => () |
297 | NONE => () |
302 val _ = print "Sledgehammering..." |
298 val _ = print "Sledgehammering..." |
303 val (smts, (ueq_atps, full_atps)) = |
299 val (smts, (ueq_atps, full_atps)) = |
304 provers |> List.partition (is_smt_prover ctxt) |
300 provers |> List.partition (is_smt_prover ctxt) |
305 ||> List.partition (is_unit_equational_atp ctxt) |
301 ||> List.partition (is_unit_equational_atp ctxt) |
306 fun launch_provers state get_facts translate maybe_smt_filter provers = |
302 fun launch_provers state get_facts translate provers = |
307 let |
303 let |
308 val facts = get_facts () |
304 val facts = get_facts () |
309 val num_facts = length facts |
305 val num_facts = length facts |
310 val facts = facts ~~ (0 upto num_facts - 1) |
306 val facts = facts ~~ (0 upto num_facts - 1) |
311 |> map (translate num_facts) |
307 |> map (translate num_facts) |
312 val problem = |
308 val problem = |
313 {state = state, goal = goal, subgoal = i, subgoal_count = n, |
309 {state = state, goal = goal, subgoal = i, subgoal_count = n, |
314 facts = facts, |
310 facts = facts} |
315 smt_filter = maybe_smt_filter |
|
316 (fn () => map_filter (try dest_SMT_Weighted_Fact) facts) i} |
|
317 val launch = launch_prover params mode minimize_command only |
311 val launch = launch_prover params mode minimize_command only |
318 in |
312 in |
319 if mode = Auto_Try orelse mode = Try then |
313 if mode = Auto_Try orelse mode = Try then |
320 (unknownN, state) |
314 (unknownN, state) |
321 |> fold (fn prover => fn accum as (outcome_code, _) => |
315 |> fold (fn prover => fn accum as (outcome_code, _) => |
375 (); |
369 (); |
376 accum) |
370 accum) |
377 else |
371 else |
378 launch_provers state |
372 launch_provers state |
379 (get_facts label is_appropriate_prop atp_relevance_fudge o K atps) |
373 (get_facts label is_appropriate_prop atp_relevance_fudge o K atps) |
380 (K (Untranslated_Fact o fst)) (K (K NONE)) atps |
374 (K (Untranslated_Fact o fst)) atps |
381 fun launch_smts accum = |
375 fun launch_smts accum = |
382 if null smts then |
376 if null smts then |
383 accum |
377 accum |
384 else |
378 else |
385 let |
379 let |
386 val facts = get_facts "SMT solver" NONE smt_relevance_fudge smts |
380 val facts = get_facts "SMT solver" NONE smt_relevance_fudge smts |
387 val weight = SMT_Weighted_Fact oo weight_smt_fact ctxt |
381 val weight = SMT_Weighted_Fact oo weight_smt_fact ctxt |
388 fun smt_filter facts = |
|
389 (if debug then curry (op o) SOME |
|
390 else TimeLimit.timeLimit timeout o try) |
|
391 (SMT_Solver.smt_filter_preprocess state (facts ())) |
|
392 in |
382 in |
393 smts |> map (`(class_of_smt_solver ctxt)) |
383 smts |> map (`(class_of_smt_solver ctxt)) |
394 |> AList.group (op =) |
384 |> AList.group (op =) |
395 |> map (snd #> launch_provers state (K facts) weight smt_filter |
385 |> map (snd #> launch_provers state (K facts) weight #> fst) |
396 #> fst) |
|
397 |> max_outcome_code |> rpair state |
386 |> max_outcome_code |> rpair state |
398 end |
387 end |
399 val launch_full_atps = launch_atps "ATP" NONE full_atps |
388 val launch_full_atps = launch_atps "ATP" NONE full_atps |
400 val launch_ueq_atps = |
389 val launch_ueq_atps = |
401 launch_atps "Unit equational provers" (SOME is_unit_equality) ueq_atps |
390 launch_atps "Unit equational provers" (SOME is_unit_equality) ueq_atps |