author | wenzelm |
Wed, 25 Jun 2025 16:35:25 +0200 | |
changeset 82768 | 8f866fd6fae1 |
parent 82620 | 2d854f1cd830 |
permissions | -rw-r--r-- |
55287 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_proof_methods.ML |
52555 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
3 |
Author: Steffen Juilf Smolka, TU Muenchen |
|
4 |
||
5 |
Reconstructors. |
|
6 |
*) |
|
7 |
||
55287 | 8 |
signature SLEDGEHAMMER_PROOF_METHODS = |
52555 | 9 |
sig |
10 |
type stature = ATP_Problem_Generate.stature |
|
11 |
||
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
12 |
datatype SMT_backend = |
72798
e732c98b02e6
tuned proof preplay to explicitly refer to Z3 backend
desharna
parents:
72518
diff
changeset
|
13 |
SMT_Z3 | |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
14 |
SMT_Verit of string |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
15 |
|
55285 | 16 |
datatype proof_method = |
82503 | 17 |
Algebra_Method | |
78695 | 18 |
Argo_Method | |
82503 | 19 |
Auto_Method | |
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
20 |
Blast_Method | |
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
21 |
Fastforce_Method | |
55285 | 22 |
Force_Method | |
82503 | 23 |
Linarith_Method | |
24 |
Meson_Method | |
|
25 |
Metis_Method of string option * string option * string list | |
|
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
26 |
Moura_Method | |
82503 | 27 |
Order_Method | |
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
28 |
Presburger_Method | |
82503 | 29 |
SATx_Method | |
30 |
Simp_Method | |
|
31 |
SMT_Method of SMT_backend |
|
52555 | 32 |
|
54824 | 33 |
datatype play_outcome = |
34 |
Played of Time.time | |
|
35 |
Play_Timed_Out of Time.time | |
|
56093 | 36 |
Play_Failed |
52555 | 37 |
|
54824 | 38 |
type one_line_params = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
39 |
((Pretty.T * stature) list * (proof_method * play_outcome)) * string * int * int |
52555 | 40 |
|
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
41 |
val is_proof_method_direct : proof_method -> bool |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
42 |
val pretty_proof_method : string -> string -> Pretty.T list -> proof_method -> Pretty.T |
72401
2783779b7dd3
removed obsolete unmaintained experimental prover Pirate
blanchet
parents:
70586
diff
changeset
|
43 |
val string_of_proof_method : string list -> proof_method -> string |
57054 | 44 |
val tac_of_proof_method : Proof.context -> thm list * thm list -> proof_method -> int -> tactic |
55211 | 45 |
val string_of_play_outcome : play_outcome -> string |
70586 | 46 |
val play_outcome_ord : play_outcome ord |
82576
a310d5b6c696
proper command message for Sledgehammer's proof methods
desharna
parents:
82503
diff
changeset
|
47 |
val try_command_line : string -> play_outcome -> string -> string |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
48 |
val one_line_proof_text : one_line_params -> string |
54495 | 49 |
end; |
52555 | 50 |
|
55287 | 51 |
structure Sledgehammer_Proof_Methods : SLEDGEHAMMER_PROOF_METHODS = |
52555 | 52 |
struct |
53 |
||
54828 | 54 |
open ATP_Util |
52555 | 55 |
open ATP_Problem_Generate |
55211 | 56 |
open ATP_Proof_Reconstruct |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
57 |
open Sledgehammer_Util |
52555 | 58 |
|
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
59 |
datatype SMT_backend = |
72798
e732c98b02e6
tuned proof preplay to explicitly refer to Z3 backend
desharna
parents:
72518
diff
changeset
|
60 |
SMT_Z3 | |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
61 |
SMT_Verit of string |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
62 |
|
55285 | 63 |
datatype proof_method = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
64 |
Metis_Method of string option * string option * string list | |
55285 | 65 |
Meson_Method | |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
66 |
SMT_Method of SMT_backend | |
56852
b38c5b9cf590
added 'satx' to Sledgehammer's portfolio (cf. 'isar_try0')
blanchet
parents:
56093
diff
changeset
|
67 |
SATx_Method | |
78695 | 68 |
Argo_Method | |
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
69 |
Blast_Method | |
55285 | 70 |
Simp_Method | |
71 |
Auto_Method | |
|
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
72 |
Fastforce_Method | |
55285 | 73 |
Force_Method | |
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
74 |
Moura_Method | |
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
75 |
Linarith_Method | |
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55315
diff
changeset
|
76 |
Presburger_Method | |
79942
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
77 |
Algebra_Method | |
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
78 |
Order_Method |
52555 | 79 |
|
54824 | 80 |
datatype play_outcome = |
81 |
Played of Time.time | |
|
82 |
Play_Timed_Out of Time.time | |
|
56093 | 83 |
Play_Failed |
52555 | 84 |
|
57739 | 85 |
type one_line_params = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
86 |
((Pretty.T * stature) list * (proof_method * play_outcome)) * string * int * int |
55211 | 87 |
|
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
88 |
fun is_proof_method_direct (Metis_Method _) = true |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
89 |
| is_proof_method_direct Meson_Method = true |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
90 |
| is_proof_method_direct (SMT_Method _) = true |
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
91 |
| is_proof_method_direct Simp_Method = true |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
92 |
| is_proof_method_direct _ = false |
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
93 |
|
58499
094efe6ac459
don't affect other subgoals with 'auto' in one-liner proofs
blanchet
parents:
58092
diff
changeset
|
94 |
fun is_proof_method_multi_goal Auto_Method = true |
094efe6ac459
don't affect other subgoals with 'auto' in one-liner proofs
blanchet
parents:
58092
diff
changeset
|
95 |
| is_proof_method_multi_goal _ = false |
094efe6ac459
don't affect other subgoals with 'auto' in one-liner proofs
blanchet
parents:
58092
diff
changeset
|
96 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
97 |
fun pretty_paren prefix suffix = Pretty.enclose (prefix ^ "(") (")" ^ suffix) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
98 |
fun pretty_maybe_paren prefix suffix [pretty] = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
99 |
if Symbol_Pos.is_identifier (content_of_pretty pretty) then |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
100 |
Pretty.block [Pretty.str prefix, pretty, Pretty.str suffix] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
101 |
else |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
102 |
pretty_paren prefix suffix [pretty] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
103 |
| pretty_maybe_paren prefix suffix pretties = pretty_paren prefix suffix pretties |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
104 |
|
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
105 |
(* |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
106 |
Combine indexed fact names for pretty-printing. |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
107 |
Example: [... "assms(1)" "assms(3)" ...] becomes [... "assms(1,3)" ...] |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
108 |
Combines only adjacent same names. |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
109 |
Input should not have same name with and without index. |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
110 |
*) |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
111 |
fun merge_indexed_facts (facts: Pretty.T list) : Pretty.T list = |
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
112 |
let |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
113 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
114 |
fun split (p: Pretty.T) : (string * string) option = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
115 |
try (unsuffix ")" o content_of_pretty) p |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
116 |
|> Option.mapPartial (first_field "(") |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
117 |
|
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
118 |
fun add_pretty (name,is) = (SOME (name,is),Pretty.str (name ^ "(" ^ is ^ ")")) |
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
119 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
120 |
fun merge ((SOME (name1,is1),p1) :: (y as (SOME (name2,is2),_)) :: zs) = |
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
121 |
if name1 = name2 |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
122 |
then merge (add_pretty (name1,is1 ^ "," ^ is2) :: zs) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
123 |
else p1 :: merge (y :: zs) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
124 |
| merge ((_,p) :: ys) = p :: merge ys |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
125 |
| merge [] = [] |
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
126 |
|
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
127 |
in |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
128 |
merge (map (`split) facts) |
80207
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
129 |
end |
ca7e7e41374e
pretty-printing sledgehammer command: merge indexed theorems
nipkow
parents:
79942
diff
changeset
|
130 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
131 |
fun pretty_proof_method prefix suffix facts meth = |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
132 |
let |
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
133 |
val meth_s = |
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
134 |
(case meth of |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
135 |
Metis_Method (NONE, NONE, additional_fact_names) => |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
136 |
implode_space ("metis" :: additional_fact_names) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
137 |
| Metis_Method (type_enc_opt, lam_trans_opt, additional_fact_names) => |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
138 |
implode_space ("metis" :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
139 |
"(" ^ commas (map_filter I [type_enc_opt, lam_trans_opt]) ^ ")" :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
140 |
additional_fact_names) |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
141 |
| Meson_Method => "meson" |
72798
e732c98b02e6
tuned proof preplay to explicitly refer to Z3 backend
desharna
parents:
72518
diff
changeset
|
142 |
| SMT_Method SMT_Z3 => "smt (z3)" |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
143 |
| SMT_Method (SMT_Verit strategy) => |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
144 |
"smt (" ^ commas ("verit" :: (if strategy = "default" then [] else [strategy])) ^ ")" |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
145 |
| SATx_Method => "satx" |
78695 | 146 |
| Argo_Method => "argo" |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
147 |
| Blast_Method => "blast" |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
148 |
| Simp_Method => if null facts then "simp" else "simp add:" |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
149 |
| Auto_Method => "auto" |
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
150 |
| Fastforce_Method => "fastforce" |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
151 |
| Force_Method => "force" |
58092
4ae52c60603a
renamed 'skolem' to 'moura' (to suggest Z3-style skolemization); reintroduced 'fastforce' to the mix of tested proof methods
blanchet
parents:
58075
diff
changeset
|
152 |
| Moura_Method => "moura" |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
153 |
| Linarith_Method => "linarith" |
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
154 |
| Presburger_Method => "presburger" |
79942
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
155 |
| Algebra_Method => "algebra" |
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
156 |
| Order_Method => "order") |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
157 |
in |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
158 |
pretty_maybe_paren prefix suffix |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
159 |
(Pretty.str meth_s :: merge_indexed_facts facts |> Pretty.breaks) |
56983
132142089ea6
use 'simp add:' syntax in Sledgehammer rather than 'using'
blanchet
parents:
56965
diff
changeset
|
160 |
end |
55285 | 161 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
162 |
fun string_of_proof_method ss = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
163 |
pretty_proof_method "" "" (map Pretty.str ss) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
164 |
#> content_of_pretty |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
165 |
|
57054 | 166 |
fun tac_of_proof_method ctxt (local_facts, global_facts) meth = |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
167 |
let |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
168 |
fun tac_of_metis (type_enc_opt, lam_trans_opt, additional_fact_names) = |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
169 |
let |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
170 |
val additional_facts = maps (thms_of_name ctxt) additional_fact_names |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
171 |
val ctxt = ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
172 |
|> Config.put Metis_Tactic.verbose false |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
173 |
|> Config.put Metis_Tactic.trace false |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
174 |
in |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
175 |
SELECT_GOAL (Metis_Tactic.metis_method ((Option.map single type_enc_opt, lam_trans_opt), |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
176 |
additional_facts @ global_facts) ctxt local_facts) |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
177 |
end |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
178 |
|
72798
e732c98b02e6
tuned proof preplay to explicitly refer to Z3 backend
desharna
parents:
72518
diff
changeset
|
179 |
fun tac_of_smt SMT_Z3 = SMT_Solver.smt_tac |
75956
1e2a9d2251b0
remove duplicate parsing for alethe; fix skolemization;
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
75040
diff
changeset
|
180 |
| tac_of_smt (SMT_Verit strategy) = Verit_Strategies.verit_tac_stgy strategy |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
181 |
in |
55285 | 182 |
(case meth of |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
183 |
Metis_Method options => tac_of_metis options |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
184 |
| SMT_Method backend => tac_of_smt backend ctxt (local_facts @ global_facts) |
62219
dbac573b27e7
preplaying of 'smt' and 'metis' more in sync with actual method
blanchet
parents:
61841
diff
changeset
|
185 |
| _ => |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
186 |
Method.insert_tac ctxt local_facts THEN' |
62219
dbac573b27e7
preplaying of 'smt' and 'metis' more in sync with actual method
blanchet
parents:
61841
diff
changeset
|
187 |
(case meth of |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
188 |
Meson_Method => Meson_Tactic.meson_general_tac ctxt global_facts |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
189 |
| Simp_Method => Simplifier.asm_full_simp_tac (ctxt addsimps global_facts) |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
190 |
| _ => |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
191 |
Method.insert_tac ctxt global_facts THEN' |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
192 |
(case meth of |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
193 |
SATx_Method => SAT.satx_tac ctxt |
78695 | 194 |
| Argo_Method => Argo_Tactic.argo_tac ctxt [] |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
195 |
| Blast_Method => blast_tac ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
196 |
| Auto_Method => SELECT_GOAL (Clasimp.auto_tac ctxt) |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
197 |
| Fastforce_Method => Clasimp.fast_force_tac ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
198 |
| Force_Method => Clasimp.force_tac ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
199 |
| Moura_Method => moura_tac ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
200 |
| Linarith_Method => Lin_Arith.tac ctxt |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
201 |
| Presburger_Method => Cooper.tac true [] [] ctxt |
79942
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
202 |
| Algebra_Method => Groebner.algebra_tac [] [] ctxt |
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78736
diff
changeset
|
203 |
| Order_Method => HOL_Order_Tac.tac [] ctxt))) |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72401
diff
changeset
|
204 |
end |
55211 | 205 |
|
54828 | 206 |
fun string_of_play_outcome (Played time) = string_of_ext_time (false, time) |
56093 | 207 |
| string_of_play_outcome (Play_Timed_Out time) = |
208 |
if time = Time.zeroTime then "" else string_of_ext_time (true, time) ^ ", timed out" |
|
54828 | 209 |
| string_of_play_outcome Play_Failed = "failed" |
210 |
||
78736
45867a453a3f
used standard Time.compare in Sledgehammer's preplay
desharna
parents:
78695
diff
changeset
|
211 |
fun play_outcome_ord (Played time1, Played time2) = Time.compare (time1, time2) |
55269 | 212 |
| play_outcome_ord (Played _, _) = LESS |
213 |
| play_outcome_ord (_, Played _) = GREATER |
|
78736
45867a453a3f
used standard Time.compare in Sledgehammer's preplay
desharna
parents:
78695
diff
changeset
|
214 |
| play_outcome_ord (Play_Timed_Out time1, Play_Timed_Out time2) = Time.compare (time1, time2) |
55269 | 215 |
| play_outcome_ord (Play_Timed_Out _, _) = LESS |
216 |
| play_outcome_ord (_, Play_Timed_Out _) = GREATER |
|
217 |
| play_outcome_ord (Play_Failed, Play_Failed) = EQUAL |
|
218 |
||
55211 | 219 |
fun apply_on_subgoal _ 1 = "by " |
220 |
| apply_on_subgoal 1 _ = "apply " |
|
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
221 |
| apply_on_subgoal i n = "prefer " ^ string_of_int i ^ " " ^ apply_on_subgoal 1 n |
55211 | 222 |
|
82387 | 223 |
fun proof_method_command meth i n extras = |
60252
2c468c062589
improved one-line preplaying (don't rely on 'using x by simp' to mean 'by (simp add: x)' and beware of inaccessible '(local.)this')
blanchet
parents:
59058
diff
changeset
|
224 |
let |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
225 |
val (indirect_facts, direct_facts) = |
73975
8d93f9ca6518
revisited ac28714b7478: more faithful preplaying with chained facts
blanchet
parents:
72798
diff
changeset
|
226 |
if is_proof_method_direct meth then ([], extras) else (extras, []) |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
227 |
val suffix = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
228 |
if is_proof_method_multi_goal meth andalso n <> 1 then "[1]" else "" |
60252
2c468c062589
improved one-line preplaying (don't rely on 'using x by simp' to mean 'by (simp add: x)' and beware of inaccessible '(local.)this')
blanchet
parents:
59058
diff
changeset
|
229 |
in |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
230 |
(if null indirect_facts then [] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
231 |
else Pretty.str "using" :: merge_indexed_facts indirect_facts) @ |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
232 |
[pretty_proof_method (apply_on_subgoal i n) suffix direct_facts meth] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
233 |
|> Pretty.block o Pretty.breaks |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
234 |
|> Pretty.symbolic_string_of (* markup string *) |
57287
68aa585269ac
given two one-liners, only show the best of the two
blanchet
parents:
57054
diff
changeset
|
235 |
end |
55211 | 236 |
|
56093 | 237 |
fun try_command_line banner play command = |
238 |
let val s = string_of_play_outcome play in |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
239 |
(* Add optional markup break (command may need multiple lines) *) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
240 |
banner ^ Markup.markup (Markup.break {width = 1, indent = 2}) " " ^ |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
241 |
Active.sendback_markup_command command ^ (s |> s <> "" ? enclose " (" ")") |
56093 | 242 |
end |
52555 | 243 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
244 |
val failed_command_line = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
245 |
prefix ("One-line proof reconstruction failed:" ^ |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
246 |
(* Add optional markup break (command may need multiple lines) *) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
247 |
Markup.markup (Markup.break {width = 1, indent = 2}) " ") |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
248 |
|
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81254
diff
changeset
|
249 |
fun one_line_proof_text ((used_facts, (meth, play)), banner, subgoal, subgoal_count) = |
82387 | 250 |
let val extra = filter_out (fn (_, (sc, _)) => sc = Chained) used_facts in |
57735
056a55b44ec7
eliminated Sledgehammer's "min" subcommand (and lots of complications in the code)
blanchet
parents:
57720
diff
changeset
|
251 |
map fst extra |
82387 | 252 |
|> proof_method_command meth subgoal subgoal_count |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80910
diff
changeset
|
253 |
|> (if play = Play_Failed then failed_command_line else try_command_line banner play) |
55211 | 254 |
end |
52555 | 255 |
|
54495 | 256 |
end; |