author | blanchet |
Sat, 12 Jul 2014 11:31:23 +0200 | |
changeset 57547 | 677b07d777c3 |
parent 57268 | 027feff882c4 |
child 57809 | a7345fae237b |
permissions | -rw-r--r-- |
55208 | 1 |
(* Title: HOL/TPTP/atp_problem_import.ML |
46324 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
3 |
Copyright 2012 |
|
4 |
||
5 |
Import TPTP problems as Isabelle terms or goals. |
|
6 |
*) |
|
7 |
||
8 |
signature ATP_PROBLEM_IMPORT = |
|
9 |
sig |
|
54434 | 10 |
val read_tptp_file : theory -> (string * term -> 'a) -> string -> |
11 |
'a list * ('a list * 'a list) * Proof.context |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
12 |
val nitpick_tptp_file : theory -> int -> string -> unit |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
13 |
val refute_tptp_file : theory -> int -> string -> unit |
47845 | 14 |
val can_tac : Proof.context -> tactic -> term -> bool |
15 |
val SOLVE_TIMEOUT : int -> string -> tactic -> tactic |
|
54434 | 16 |
val atp_tac : Proof.context -> int -> (string * string) list -> int -> string -> int -> tactic |
47845 | 17 |
val smt_solver_tac : string -> Proof.context -> int -> tactic |
18 |
val freeze_problem_consts : theory -> term -> term |
|
19 |
val make_conj : term list * term list -> term list -> term |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
20 |
val sledgehammer_tptp_file : theory -> int -> string -> unit |
48083
a4148c95134d
renamed TPTP commands to agree with Sutcliffe's terminology
blanchet
parents:
48082
diff
changeset
|
21 |
val isabelle_tptp_file : theory -> int -> string -> unit |
a4148c95134d
renamed TPTP commands to agree with Sutcliffe's terminology
blanchet
parents:
48082
diff
changeset
|
22 |
val isabelle_hot_tptp_file : theory -> int -> string -> unit |
54472
073f041d83ae
send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents:
54434
diff
changeset
|
23 |
val translate_tptp_file : theory -> string -> string -> unit |
46324 | 24 |
end; |
25 |
||
26 |
structure ATP_Problem_Import : ATP_PROBLEM_IMPORT = |
|
27 |
struct |
|
28 |
||
47643
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
29 |
open ATP_Util |
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
30 |
open ATP_Problem |
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
31 |
open ATP_Proof |
54434 | 32 |
open ATP_Problem_Generate |
33 |
open ATP_Systems |
|
47643
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
34 |
|
47776
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
35 |
val debug = false |
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
36 |
val overlord = false |
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
37 |
|
47643
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
38 |
|
47771 | 39 |
(** TPTP parsing **) |
47643
e33c2be488fe
reintroduced old FOF and CNF parsers, to work around TPTP_Parser failures
blanchet
parents:
47565
diff
changeset
|
40 |
|
54434 | 41 |
fun exploded_absolute_path file_name = |
42 |
Path.explode file_name |
|
43 |
|> (fn path => path |> not (Path.is_absolute path) ? Path.append (Path.explode "$PWD")) |
|
44 |
||
47785 | 45 |
fun read_tptp_file thy postproc file_name = |
47644 | 46 |
let |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
47 |
fun has_role role (_, role', _, _) = (role' = role) |
54434 | 48 |
fun get_prop (name, role, P, info) = |
49 |
let val P' = P |> Logic.varify_global |> close_form in |
|
50 |
(name, P') |> postproc |
|
51 |
end |
|
52 |
val path = exploded_absolute_path file_name |
|
47714 | 53 |
val ((_, _, problem), thy) = |
48829
6ed588c4f963
look in current directory first before looking up includes in the TPTP directory, as required by Geoff
blanchet
parents:
48143
diff
changeset
|
54 |
TPTP_Interpret.interpret_file true [Path.dir path, Path.explode "$TPTP"] |
6ed588c4f963
look in current directory first before looking up includes in the TPTP directory, as required by Geoff
blanchet
parents:
48143
diff
changeset
|
55 |
path [] [] thy |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
56 |
val (conjs, defs_and_nondefs) = |
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
57 |
problem |> List.partition (has_role TPTP_Syntax.Role_Conjecture) |
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
58 |
||> List.partition (has_role TPTP_Syntax.Role_Definition) |
47644 | 59 |
in |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
60 |
(map get_prop conjs, pairself (map get_prop) defs_and_nondefs, |
52788 | 61 |
thy |> Proof_Context.init_global) |
47557
32f35b3d9e42
started integrating Nik's parser into TPTP command-line tools
blanchet
parents:
46325
diff
changeset
|
62 |
end |
46325 | 63 |
|
47771 | 64 |
|
57547
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
65 |
(** Nitpick **) |
46324 | 66 |
|
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
67 |
fun aptrueprop f ((t0 as @{const Trueprop}) $ t1) = t0 $ f t1 |
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
68 |
| aptrueprop f t = f t |
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
69 |
|
57547
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
70 |
fun is_legitimate_tptp_def (@{const Trueprop} $ t) = is_legitimate_tptp_def t |
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
71 |
| is_legitimate_tptp_def (Const (@{const_name HOL.eq}, _) $ t $ u) = |
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
72 |
(is_Const t orelse is_Free t) andalso not (exists_subterm (curry (op =) t) u) |
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
73 |
| is_legitimate_tptp_def _ = false |
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
74 |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
75 |
fun nitpick_tptp_file thy timeout file_name = |
46325 | 76 |
let |
54434 | 77 |
val (conjs, (defs, nondefs), ctxt) = read_tptp_file thy snd file_name |
47771 | 78 |
val thy = Proof_Context.theory_of ctxt |
47991
3eb598b044ad
make Nitpick's handling of definitions more robust in the face of formulas that don't have the expected format (needed for soundness, cf. RNG100+1)
blanchet
parents:
47957
diff
changeset
|
79 |
val (defs, pseudo_defs) = |
3eb598b044ad
make Nitpick's handling of definitions more robust in the face of formulas that don't have the expected format (needed for soundness, cf. RNG100+1)
blanchet
parents:
47957
diff
changeset
|
80 |
defs |> map (ATP_Util.abs_extensionalize_term ctxt |
49985
5b4b0e4e5205
moved Refute to "HOL/Library" to speed up building "Main" even more
blanchet
parents:
49983
diff
changeset
|
81 |
#> aptrueprop (hol_open_form I)) |
57547
677b07d777c3
don't generate TPTP THF 'Definition's, because they complicate reconstruction for AgsyHOL and Satallax
blanchet
parents:
57268
diff
changeset
|
82 |
|> List.partition (is_legitimate_tptp_def |
47991
3eb598b044ad
make Nitpick's handling of definitions more robust in the face of formulas that don't have the expected format (needed for soundness, cf. RNG100+1)
blanchet
parents:
47957
diff
changeset
|
83 |
o perhaps (try HOLogic.dest_Trueprop) |
3eb598b044ad
make Nitpick's handling of definitions more robust in the face of formulas that don't have the expected format (needed for soundness, cf. RNG100+1)
blanchet
parents:
47957
diff
changeset
|
84 |
o ATP_Util.unextensionalize_def) |
3eb598b044ad
make Nitpick's handling of definitions more robust in the face of formulas that don't have the expected format (needed for soundness, cf. RNG100+1)
blanchet
parents:
47957
diff
changeset
|
85 |
val nondefs = pseudo_defs @ nondefs |
47714 | 86 |
val state = Proof.init ctxt |
46325 | 87 |
val params = |
47557
32f35b3d9e42
started integrating Nik's parser into TPTP command-line tools
blanchet
parents:
46325
diff
changeset
|
88 |
[("card", "1\<emdash>100"), |
46325 | 89 |
("box", "false"), |
90 |
("max_threads", "1"), |
|
47791 | 91 |
("batch_size", "5"), |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
92 |
("falsify", if null conjs then "false" else "true"), |
46325 | 93 |
("verbose", "true"), |
47776
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
94 |
("debug", if debug then "true" else "false"), |
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
95 |
("overlord", if overlord then "true" else "false"), |
46325 | 96 |
("show_consts", "true"), |
47755 | 97 |
("format", "1"), |
46325 | 98 |
("max_potential", "0"), |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
99 |
("timeout", string_of_int timeout), |
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
100 |
("tac_timeout", string_of_int ((timeout + 49) div 50))] |
55199 | 101 |
|> Nitpick_Commands.default_params thy |
46325 | 102 |
val i = 1 |
103 |
val n = 1 |
|
104 |
val step = 0 |
|
105 |
val subst = [] |
|
106 |
in |
|
47715
04400144c6fc
handle TPTP definitions as definitions in Nitpick rather than as axioms
blanchet
parents:
47714
diff
changeset
|
107 |
Nitpick.pick_nits_in_term state params Nitpick.TPTP i n step subst |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
108 |
defs nondefs (case conjs of conj :: _ => conj | [] => @{prop True}); |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
109 |
() |
46325 | 110 |
end |
46324 | 111 |
|
112 |
||
113 |
(** Refute **) |
|
114 |
||
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
115 |
fun refute_tptp_file thy timeout file_name = |
46325 | 116 |
let |
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51717
diff
changeset
|
117 |
fun print_szs_of_outcome falsify s = |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
118 |
"% SZS status " ^ |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
119 |
(if s = "genuine" then |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
120 |
if falsify then "CounterSatisfiable" else "Satisfiable" |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
121 |
else |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
122 |
"Unknown") |
47788 | 123 |
|> Output.urgent_message |
54434 | 124 |
val (conjs, (defs, nondefs), ctxt) = read_tptp_file thy snd file_name |
46325 | 125 |
val params = |
47714 | 126 |
[("maxtime", string_of_int timeout), |
127 |
("maxvars", "100000")] |
|
46325 | 128 |
in |
47718
39229c760636
smoother handling of conjecture, so that its Skolem constants get displayed in countermodels
blanchet
parents:
47715
diff
changeset
|
129 |
Refute.refute_term ctxt params (defs @ nondefs) |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
130 |
(case conjs of conj :: _ => conj | [] => @{prop True}) |
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51717
diff
changeset
|
131 |
|> print_szs_of_outcome (not (null conjs)) |
46325 | 132 |
end |
46324 | 133 |
|
134 |
||
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
135 |
(** Sledgehammer and Isabelle (combination of provers) **) |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
136 |
|
47785 | 137 |
fun can_tac ctxt tactic conj = can (Goal.prove ctxt [] [] conj) (K tactic) |
47771 | 138 |
|
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
139 |
fun SOLVE_TIMEOUT seconds name tac st = |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
140 |
let |
47788 | 141 |
val _ = Output.urgent_message ("running " ^ name ^ " for " ^ |
142 |
string_of_int seconds ^ " s") |
|
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
143 |
val result = |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
144 |
TimeLimit.timeLimit (Time.fromSeconds seconds) |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
145 |
(fn () => SINGLE (SOLVE tac) st) () |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
146 |
handle TimeLimit.TimeOut => NONE |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
147 |
| ERROR _ => NONE |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
148 |
in |
47785 | 149 |
case result of |
47788 | 150 |
NONE => (Output.urgent_message ("FAILURE: " ^ name); Seq.empty) |
151 |
| SOME st' => (Output.urgent_message ("SUCCESS: " ^ name); Seq.single st') |
|
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
152 |
end |
46324 | 153 |
|
47812 | 154 |
fun nitpick_finite_oracle_tac ctxt timeout i th = |
155 |
let |
|
156 |
fun is_safe (Type (@{type_name fun}, Ts)) = forall is_safe Ts |
|
157 |
| is_safe @{typ prop} = true |
|
158 |
| is_safe @{typ bool} = true |
|
159 |
| is_safe _ = false |
|
160 |
val conj = Thm.term_of (Thm.cprem_of th i) |
|
161 |
in |
|
162 |
if exists_type (not o is_safe) conj then |
|
163 |
Seq.empty |
|
164 |
else |
|
165 |
let |
|
166 |
val thy = Proof_Context.theory_of ctxt |
|
167 |
val state = Proof.init ctxt |
|
168 |
val params = |
|
169 |
[("box", "false"), |
|
170 |
("max_threads", "1"), |
|
171 |
("verbose", "true"), |
|
172 |
("debug", if debug then "true" else "false"), |
|
173 |
("overlord", if overlord then "true" else "false"), |
|
174 |
("max_potential", "0"), |
|
175 |
("timeout", string_of_int timeout)] |
|
55199 | 176 |
|> Nitpick_Commands.default_params thy |
47812 | 177 |
val i = 1 |
178 |
val n = 1 |
|
179 |
val step = 0 |
|
180 |
val subst = [] |
|
181 |
val (outcome, _) = |
|
182 |
Nitpick.pick_nits_in_term state params Nitpick.Normal i n step subst |
|
183 |
[] [] conj |
|
51552
c713c9505f68
clarified Skip_Proof.cheat_tac: more standard tactic;
wenzelm
parents:
49985
diff
changeset
|
184 |
in if outcome = "none" then ALLGOALS Skip_Proof.cheat_tac th else Seq.empty end |
47812 | 185 |
end |
186 |
||
48143 | 187 |
fun atp_tac ctxt completeness override_params timeout prover = |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
188 |
let |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
189 |
val ctxt = |
55212 | 190 |
ctxt |> Config.put Sledgehammer_Prover_ATP.atp_completish (completeness > 0) |
52071 | 191 |
fun ref_of th = (Facts.named (Thm.derivation_name th), []) |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
192 |
in |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
193 |
Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
194 |
([("debug", if debug then "true" else "false"), |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
195 |
("overlord", if overlord then "true" else "false"), |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
196 |
("provers", prover), |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
197 |
("timeout", string_of_int timeout)] @ |
48143 | 198 |
(if completeness > 0 then |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
199 |
[("type_enc", |
52071 | 200 |
if completeness = 1 then "mono_native" else "poly_tags")] |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
201 |
else |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
202 |
[]) @ |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
203 |
override_params) |
52071 | 204 |
{add = map ref_of [ext, @{thm someI}], del = [], only = true} |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
205 |
end |
47765 | 206 |
|
47832 | 207 |
fun sledgehammer_tac demo ctxt timeout i = |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
208 |
let |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
209 |
val frac = if demo then 16 else 12 |
48143 | 210 |
fun slice mult completeness prover = |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
211 |
SOLVE_TIMEOUT (mult * timeout div frac) |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
212 |
(prover ^ |
48143 | 213 |
(if completeness > 0 then "(" ^ string_of_int completeness ^ ")" |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
214 |
else "")) |
48143 | 215 |
(atp_tac ctxt completeness [] (mult * timeout div frac) prover i) |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
216 |
in |
57154 | 217 |
slice 2 0 ATP_Proof.spassN |
218 |
ORELSE slice 2 0 ATP_Proof.vampireN |
|
219 |
ORELSE slice 2 0 ATP_Proof.eN |
|
220 |
ORELSE slice 2 0 ATP_Proof.z3_tptpN |
|
221 |
ORELSE slice 1 1 ATP_Proof.spassN |
|
222 |
ORELSE slice 1 2 ATP_Proof.eN |
|
223 |
ORELSE slice 1 1 ATP_Proof.vampireN |
|
224 |
ORELSE slice 1 2 ATP_Proof.vampireN |
|
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
225 |
ORELSE |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
226 |
(if demo then |
57154 | 227 |
slice 2 0 ATP_Proof.satallaxN |
228 |
ORELSE slice 2 0 ATP_Proof.leo2N |
|
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
229 |
else |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
230 |
no_tac) |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
231 |
end |
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
232 |
|
47832 | 233 |
fun smt_solver_tac solver ctxt = |
234 |
let |
|
235 |
val ctxt = ctxt |> Context.proof_map (SMT_Config.select_solver solver) |
|
236 |
in SMT_Solver.smt_tac ctxt [] end |
|
237 |
||
47785 | 238 |
fun auto_etc_tac ctxt timeout i = |
47812 | 239 |
SOLVE_TIMEOUT (timeout div 20) "nitpick" |
240 |
(nitpick_finite_oracle_tac ctxt (timeout div 20) i) |
|
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
241 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "simp" |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51552
diff
changeset
|
242 |
(asm_full_simp_tac ctxt i) |
47788 | 243 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "blast" (blast_tac ctxt i) |
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
244 |
ORELSE SOLVE_TIMEOUT (timeout div 5) "auto+spass" |
47785 | 245 |
(auto_tac ctxt |
57154 | 246 |
THEN ALLGOALS (atp_tac ctxt 0 [] (timeout div 5) ATP_Proof.spassN)) |
47946
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
247 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "fast" (fast_tac ctxt i) |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
248 |
ORELSE SOLVE_TIMEOUT (timeout div 20) "z3" (smt_solver_tac "z3" ctxt i) |
33afcfad3f8d
add an experimental "aggressive" mode to Sledgehammer, to experiment with more complete translations of higher-order features without breaking "metis"
blanchet
parents:
47845
diff
changeset
|
249 |
ORELSE SOLVE_TIMEOUT (timeout div 20) "cvc3" (smt_solver_tac "cvc3" ctxt i) |
47812 | 250 |
ORELSE SOLVE_TIMEOUT (timeout div 20) "best" (best_tac ctxt i) |
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
251 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "force" (force_tac ctxt i) |
47832 | 252 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "meson" (Meson.meson_tac ctxt [] i) |
47812 | 253 |
ORELSE SOLVE_TIMEOUT (timeout div 10) "fastforce" (fast_force_tac ctxt i) |
47771 | 254 |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
255 |
fun problem_const_prefix thy = Context.theory_name thy ^ Long_Name.separator |
47785 | 256 |
|
257 |
(* Isabelle's standard automatic tactics ("auto", etc.) are more eager to |
|
258 |
unfold "definitions" of free variables than of constants (cf. PUZ107^5). *) |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
259 |
fun freeze_problem_consts thy = |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
260 |
let val is_problem_const = String.isPrefix (problem_const_prefix thy) in |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
261 |
map_aterms (fn t as Const (s, T) => |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
262 |
if is_problem_const s then Free (Long_Name.base_name s, T) |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
263 |
else t |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
264 |
| t => t) |
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
265 |
end |
47785 | 266 |
|
47776
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
267 |
fun make_conj (defs, nondefs) conjs = |
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
268 |
Logic.list_implies (rev defs @ rev nondefs, |
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
269 |
case conjs of conj :: _ => conj | [] => @{prop False}) |
47771 | 270 |
|
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51717
diff
changeset
|
271 |
fun print_szs_of_success conjs success = |
47788 | 272 |
Output.urgent_message ("% SZS status " ^ |
273 |
(if success then |
|
274 |
if null conjs then "Unsatisfiable" else "Theorem" |
|
275 |
else |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
276 |
"Unknown")) |
47765 | 277 |
|
47794
4ad62c5f9f88
thread theory cleanly and use "smt" method rather than Sledgehammer for Z3 (because of obscure debilitating bug)
blanchet
parents:
47793
diff
changeset
|
278 |
fun sledgehammer_tptp_file thy timeout file_name = |
47771 | 279 |
let |
47785 | 280 |
val (conjs, assms, ctxt) = |
54434 | 281 |
read_tptp_file thy (freeze_problem_consts thy o snd) file_name |
47776
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
282 |
val conj = make_conj assms conjs |
47771 | 283 |
in |
47832 | 284 |
can_tac ctxt (sledgehammer_tac true ctxt timeout 1) conj |
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51717
diff
changeset
|
285 |
|> print_szs_of_success conjs |
47771 | 286 |
end |
47766
9f7cdd5fff7c
more work on TPTP Isabelle and Sledgehammer tactics
blanchet
parents:
47765
diff
changeset
|
287 |
|
48083
a4148c95134d
renamed TPTP commands to agree with Sutcliffe's terminology
blanchet
parents:
48082
diff
changeset
|
288 |
fun generic_isabelle_tptp_file demo thy timeout file_name = |
47771 | 289 |
let |
47785 | 290 |
val (conjs, assms, ctxt) = |
54434 | 291 |
read_tptp_file thy (freeze_problem_consts thy o snd) file_name |
47776
024cf0f7fb6d
further tweaking for Satallax, so that TPTP problems before parsing and after generation are as similar as possible/practical
blanchet
parents:
47771
diff
changeset
|
292 |
val conj = make_conj assms conjs |
48143 | 293 |
val (last_hope_atp, last_hope_completeness) = |
57154 | 294 |
if demo then (ATP_Proof.satallaxN, 0) else (ATP_Proof.vampireN, 2) |
47771 | 295 |
in |
47811 | 296 |
(can_tac ctxt (auto_etc_tac ctxt (timeout div 2) 1) conj orelse |
47832 | 297 |
can_tac ctxt (sledgehammer_tac demo ctxt (timeout div 2) 1) conj orelse |
48082 | 298 |
can_tac ctxt (SOLVE_TIMEOUT timeout (last_hope_atp ^ "(*)") |
48143 | 299 |
(atp_tac ctxt last_hope_completeness [] timeout last_hope_atp 1)) conj) |
52031
9a9238342963
tuning -- renamed '_from_' to '_of_' in Sledgehammer
blanchet
parents:
51717
diff
changeset
|
300 |
|> print_szs_of_success conjs |
47771 | 301 |
end |
46324 | 302 |
|
48083
a4148c95134d
renamed TPTP commands to agree with Sutcliffe's terminology
blanchet
parents:
48082
diff
changeset
|
303 |
val isabelle_tptp_file = generic_isabelle_tptp_file false |
a4148c95134d
renamed TPTP commands to agree with Sutcliffe's terminology
blanchet
parents:
48082
diff
changeset
|
304 |
val isabelle_hot_tptp_file = generic_isabelle_tptp_file true |
47832 | 305 |
|
306 |
||
46324 | 307 |
(** Translator between TPTP(-like) file formats **) |
308 |
||
54472
073f041d83ae
send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents:
54434
diff
changeset
|
309 |
fun translate_tptp_file thy format_str file_name = |
54434 | 310 |
let |
54472
073f041d83ae
send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents:
54434
diff
changeset
|
311 |
val (conjs, (defs, nondefs), ctxt) = read_tptp_file thy I file_name |
54434 | 312 |
val conj = make_conj ([], []) (map snd conjs) |
313 |
||
314 |
val (format, type_enc, lam_trans) = |
|
315 |
(case format_str of |
|
316 |
"FOF" => (FOF, "mono_guards??", liftingN) |
|
54547
c999e2533487
renamed TFF0/THF0 to three-letter acronyms, in keeping with new TPTP policy
blanchet
parents:
54472
diff
changeset
|
317 |
| "TF0" => (TFF Monomorphic, "mono_native", liftingN) |
c999e2533487
renamed TFF0/THF0 to three-letter acronyms, in keeping with new TPTP policy
blanchet
parents:
54472
diff
changeset
|
318 |
| "TH0" => (THF (Monomorphic, THF_Without_Choice), "mono_native_higher", keep_lamsN) |
54434 | 319 |
| "DFG" => (DFG Monomorphic, "mono_native", liftingN) |
320 |
| _ => error ("Unknown format " ^ quote format_str ^ |
|
54547
c999e2533487
renamed TFF0/THF0 to three-letter acronyms, in keeping with new TPTP policy
blanchet
parents:
54472
diff
changeset
|
321 |
" (expected \"FOF\", \"TF0\", \"TH0\", or \"DFG\")")) |
54434 | 322 |
val uncurried_aliases = false |
323 |
val readable_names = true |
|
324 |
val presimp = true |
|
325 |
val facts = map (apfst (rpair (Global, Non_Rec_Def))) defs @ |
|
326 |
map (apfst (rpair (Global, General))) nondefs |
|
57268 | 327 |
val (atp_problem, _, _, _) = |
328 |
generate_atp_problem ctxt format Hypothesis (type_enc_of_string Strict type_enc) Translator |
|
54434 | 329 |
lam_trans uncurried_aliases readable_names presimp [] conj facts |
330 |
||
331 |
val ord = effective_term_order ctxt spassN |
|
332 |
val ord_info = K [] |
|
333 |
val lines = lines_of_atp_problem format ord ord_info atp_problem |
|
334 |
in |
|
54472
073f041d83ae
send output of "tptp_translate" to standard output, to simplify Geoff Sutcliffe's life
blanchet
parents:
54434
diff
changeset
|
335 |
List.app Output.physical_stdout lines |
54434 | 336 |
end |
46324 | 337 |
|
338 |
end; |