author | paulson <lp15@cam.ac.uk> |
Wed, 30 May 2018 23:11:12 +0100 | |
changeset 68326 | 3c71695ff7ce |
parent 62738 | fe827c6fa8c5 |
permissions | -rw-r--r-- |
47790 | 1 |
(* Title: HOL/TPTP/sledgehammer_tactics.ML |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
2 |
Author: Jasmin Blanchette, TU Muenchen |
42071
04577a7e0c51
move "TPTP" wrapper and "Sledgehammer as a tactic" to "HOL/ex"
blanchet
parents:
41959
diff
changeset
|
3 |
Copyright 2010, 2011 |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
4 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
5 |
Sledgehammer as a tactic. |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
6 |
*) |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
7 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
8 |
signature SLEDGEHAMMER_TACTICS = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
9 |
sig |
48292 | 10 |
type fact_override = Sledgehammer_Fact.fact_override |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44429
diff
changeset
|
11 |
|
57754 | 12 |
val sledgehammer_with_metis_tac : Proof.context -> (string * string) list -> fact_override -> |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
13 |
thm list -> int -> tactic |
57754 | 14 |
val sledgehammer_as_oracle_tac : Proof.context -> (string * string) list -> fact_override -> |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
15 |
thm list -> int -> tactic |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
16 |
end; |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
17 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
18 |
structure Sledgehammer_Tactics : SLEDGEHAMMER_TACTICS = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
19 |
struct |
42071
04577a7e0c51
move "TPTP" wrapper and "Sledgehammer as a tactic" to "HOL/ex"
blanchet
parents:
41959
diff
changeset
|
20 |
|
48299 | 21 |
open Sledgehammer_Util |
48287 | 22 |
open Sledgehammer_Fact |
55201 | 23 |
open Sledgehammer_Prover |
55212 | 24 |
open Sledgehammer_Prover_ATP |
55205 | 25 |
open Sledgehammer_Prover_Minimize |
48381 | 26 |
open Sledgehammer_MaSh |
55198 | 27 |
open Sledgehammer_Commands |
44462
d9a657c44380
more reliable "sledgehammer\_tac" reconstruction, by avoiding "insert_tac"
blanchet
parents:
44429
diff
changeset
|
28 |
|
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
29 |
fun run_prover override_params fact_override chained i n ctxt goal = |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
30 |
let |
55205 | 31 |
val thy = Proof_Context.theory_of ctxt |
48299 | 32 |
val mode = Normal |
55205 | 33 |
val params as {provers, max_facts, ...} = default_params thy override_params |
44429 | 34 |
val name = hd provers |
48299 | 35 |
val prover = get_prover ctxt mode name |
54126
6675cdc0d1ae
if slicing is disabled, pick the maximum number of facts, not the number of facts in the last slice
blanchet
parents:
52196
diff
changeset
|
36 |
val default_max_facts = default_max_facts_of_prover ctxt name |
52196
2281f33e8da6
redid rac7830871177 to avoid duplicate fixed variable (e.g. lemma "P (a::nat)" proof - have "!!a::int. Q a" sledgehammer [e])
blanchet
parents:
52125
diff
changeset
|
37 |
val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal goal i ctxt |
48299 | 38 |
val ho_atp = exists (is_ho_atp ctxt) provers |
58928
23d0ffd48006
plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents:
58921
diff
changeset
|
39 |
val keywords = Thy_Header.get_keywords' ctxt |
48299 | 40 |
val css_table = clasimpset_rule_table_of ctxt |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
41 |
val facts = |
58921
ffdafc99f67b
prefer explicit Keyword.keywords (cf. 82a71046dce8);
wenzelm
parents:
57812
diff
changeset
|
42 |
nearly_all_facts ctxt ho_atp fact_override keywords css_table chained hyp_ts concl_t |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
43 |
|> relevant_facts ctxt params name (the_default default_max_facts max_facts) fact_override |
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
44 |
hyp_ts concl_t |
51010 | 45 |
|> hd |> snd |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
46 |
val problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
47 |
{comment = "", state = Proof.init ctxt, goal = goal, subgoal = i, subgoal_count = n, |
62738 | 48 |
factss = [("", facts)], found_proof = I} |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
49 |
in |
57754 | 50 |
(case prover params problem of |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
51 |
{outcome = NONE, used_facts, ...} => used_facts |> map fst |> SOME |
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
52 |
| _ => NONE) |
51010 | 53 |
handle ERROR message => (warning ("Error: " ^ message ^ "\n"); NONE) |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
54 |
end |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
55 |
|
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
56 |
fun sledgehammer_with_metis_tac ctxt override_params fact_override chained i th = |
48292 | 57 |
let val override_params = override_params @ [("preplay_timeout", "0")] in |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
58 |
(case run_prover override_params fact_override chained i i ctxt th of |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
59 |
SOME facts => |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
60 |
Metis_Tactic.metis_tac [] ATP_Problem_Generate.combs_or_liftingN ctxt |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
61 |
(maps (thms_of_name ctxt) facts) i th |
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
62 |
| NONE => Seq.empty) |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
63 |
end |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
64 |
|
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
65 |
fun sledgehammer_as_oracle_tac ctxt override_params fact_override chained i th = |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
66 |
let |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
67 |
val override_params = |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
68 |
override_params @ |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
69 |
[("preplay_timeout", "0"), |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47532
diff
changeset
|
70 |
("minimize", "false")] |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
71 |
val xs = run_prover override_params fact_override chained i i ctxt th |
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
72 |
in |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
58928
diff
changeset
|
73 |
if is_some xs then ALLGOALS (Skip_Proof.cheat_tac ctxt) th else Seq.empty |
57812
8dc9dc241973
make TPTP tools work on polymorphic (TFF1) problems as well
blanchet
parents:
57754
diff
changeset
|
74 |
end |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
75 |
|
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
76 |
end; |