author | blanchet |
Mon, 22 Aug 2011 15:02:45 +0200 | |
changeset 44390 | 99ef9fd7341b |
parent 43351 | b19d95b4d736 |
child 44429 | e5506cfe1b5a |
permissions | -rw-r--r-- |
42071
04577a7e0c51
move "TPTP" wrapper and "Sledgehammer as a tactic" to "HOL/ex"
blanchet
parents:
41959
diff
changeset
|
1 |
(* Title: HOL/ex/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 |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
10 |
val sledgehammer_with_metis_tac : Proof.context -> int -> tactic |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
11 |
val sledgehammer_as_unsound_oracle_tac : Proof.context -> int -> tactic |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
12 |
val sledgehammer_as_oracle_tac : Proof.context -> int -> tactic |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
13 |
end; |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
14 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
15 |
structure Sledgehammer_Tactics : SLEDGEHAMMER_TACTICS = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
16 |
struct |
42071
04577a7e0c51
move "TPTP" wrapper and "Sledgehammer as a tactic" to "HOL/ex"
blanchet
parents:
41959
diff
changeset
|
17 |
|
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
18 |
fun run_atp force_full_types timeout i n ctxt goal name = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
19 |
let |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
20 |
val chained_ths = [] (* a tactic has no chained ths *) |
42642 | 21 |
val params as {relevance_thresholds, max_relevant, slicing, ...} = |
44390 | 22 |
((if force_full_types then [("sound", "true")] else []) |
41491 | 23 |
@ [("timeout", string_of_int (Time.toSeconds timeout))]) |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
24 |
(* @ [("overlord", "true")] *) |
40635
47004929bc71
ported sledgehammer_tactic to current development version
bulwahn
parents:
40633
diff
changeset
|
25 |
|> Sledgehammer_Isar.default_params ctxt |
43021 | 26 |
val prover = |
27 |
Sledgehammer_Provers.get_prover ctxt Sledgehammer_Provers.Normal name |
|
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
28 |
val default_max_relevant = |
42443
724e612ba248
implemented general slicing for ATPs, especially E 1.2w and above
blanchet
parents:
42361
diff
changeset
|
29 |
Sledgehammer_Provers.default_max_relevant_for_prover ctxt slicing name |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
30 |
val is_built_in_const = |
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
31 |
Sledgehammer_Provers.is_built_in_const_for_prover ctxt name |
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
32 |
val relevance_fudge = |
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
40983
diff
changeset
|
33 |
Sledgehammer_Provers.relevance_fudge_for_prover ctxt name |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
34 |
val relevance_override = {add = [], del = [], only = false} |
43088 | 35 |
val (_, hyp_ts, concl_t) = ATP_Util.strip_subgoal ctxt goal i |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
36 |
val facts = |
43351
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43212
diff
changeset
|
37 |
Sledgehammer_Filter.nearly_all_facts ctxt relevance_override chained_ths |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43212
diff
changeset
|
38 |
hyp_ts concl_t |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43212
diff
changeset
|
39 |
|> Sledgehammer_Filter.relevant_facts ctxt relevance_thresholds |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43212
diff
changeset
|
40 |
(the_default default_max_relevant max_relevant) is_built_in_const |
b19d95b4d736
compute the set of base facts only once (instead of three times in parallel) -- this saves about .5 s of CPU time, albeit much less clock wall time
blanchet
parents:
43212
diff
changeset
|
41 |
relevance_fudge relevance_override chained_ths hyp_ts concl_t |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
42 |
val problem = |
41090 | 43 |
{state = Proof.init ctxt, goal = goal, subgoal = i, subgoal_count = n, |
41243 | 44 |
facts = map Sledgehammer_Provers.Untranslated_Fact facts, |
41741 | 45 |
smt_filter = NONE} |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
46 |
in |
43051 | 47 |
(case prover params (K (K "")) problem of |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
48 |
{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
|
49 |
| _ => NONE) |
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
50 |
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
|
51 |
end |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
52 |
|
42071
04577a7e0c51
move "TPTP" wrapper and "Sledgehammer as a tactic" to "HOL/ex"
blanchet
parents:
41959
diff
changeset
|
53 |
val atp = "e" (* or "vampire" or "spass" etc. *) |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
54 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
55 |
fun thms_of_name ctxt name = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
56 |
let |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
57 |
val lex = Keyword.get_lexicons |
42361 | 58 |
val get = maps (Proof_Context.get_fact ctxt o fst) |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
59 |
in |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
60 |
Source.of_string name |
40635
47004929bc71
ported sledgehammer_tactic to current development version
bulwahn
parents:
40633
diff
changeset
|
61 |
|> Symbol.source |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
62 |
|> Token.source {do_recover=SOME false} lex Position.start |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
63 |
|> Token.source_proper |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
64 |
|> Source.source Token.stopper (Parse_Spec.xthms1 >> get) NONE |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
65 |
|> Source.exhaust |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
66 |
end |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
67 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
68 |
fun sledgehammer_with_metis_tac ctxt i th = |
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
69 |
let |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
70 |
val timeout = Time.fromSeconds 30 |
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
71 |
in |
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
72 |
case run_atp false timeout i i ctxt th atp of |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
73 |
SOME facts => |
43212 | 74 |
Metis_Tactics.metis_tac [] ctxt (maps (thms_of_name ctxt) facts) i th |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
75 |
| NONE => Seq.empty |
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
76 |
end |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
77 |
|
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
78 |
fun generic_sledgehammer_as_oracle_tac force_full_types ctxt i th = |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
79 |
let |
42361 | 80 |
val thy = Proof_Context.theory_of ctxt |
40921
a516fbdd9931
improving sledgehammer_tactic and adding relevance filtering to the tactic
bulwahn
parents:
40635
diff
changeset
|
81 |
val timeout = Time.fromSeconds 30 |
41357
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
82 |
val xs = run_atp force_full_types timeout i i ctxt th atp |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
83 |
in if is_some xs then Skip_Proof.cheat_tac thy th else Seq.empty end |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
84 |
|
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
85 |
val sledgehammer_as_unsound_oracle_tac = |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
86 |
generic_sledgehammer_as_oracle_tac false |
ae76960d86a2
added "sledgehammer_tac" as possible reconstructor in Mirabelle
blanchet
parents:
41243
diff
changeset
|
87 |
val sledgehammer_as_oracle_tac = generic_sledgehammer_as_oracle_tac true |
40633
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
88 |
|
6cd611ceb64e
adding files to use sledgehammer as a tactic for non-interactive use
bulwahn
parents:
diff
changeset
|
89 |
end; |