author | paulson |
Thu, 15 Sep 2005 11:15:52 +0200 | |
changeset 17404 | d16c3a62c396 |
parent 17317 | 3f12de2e2e6e |
child 17422 | 3b237822985d |
permissions | -rw-r--r-- |
15608 | 1 |
(* Author: Jia Meng, Cambridge University Computer Laboratory |
2 |
ID: $Id$ |
|
3 |
Copyright 2004 University of Cambridge |
|
15347 | 4 |
|
5 |
ATPs with TPTP format input. |
|
6 |
*) |
|
15452 | 7 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
8 |
signature RES_ATP = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
9 |
sig |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
10 |
val axiom_file : Path.T |
17306 | 11 |
val prover: string ref |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
12 |
val custom_spass: string list ref |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
13 |
val hook_count: int ref |
15347 | 14 |
end; |
15 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
16 |
structure ResAtp: RES_ATP = |
15347 | 17 |
struct |
18 |
||
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
19 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
20 |
val call_atp = ref false; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
21 |
val hook_count = ref 0; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
22 |
|
16904 | 23 |
fun debug_tac tac = (debug "testing"; tac); |
16478 | 24 |
|
17404
d16c3a62c396
the experimental tagging system, and the usual tidying
paulson
parents:
17317
diff
changeset
|
25 |
val prover = ref "E"; (* use E as the default prover *) |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
26 |
val custom_spass = (*specialized options for SPASS*) |
17317
3f12de2e2e6e
Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset
|
27 |
ref ["Auto=0","-FullRed=0","-IORe","-IOFc","-RTaut","-RFSub","-RBSub", |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
28 |
"-DocProof","-TimeLimit=60"]; |
15347 | 29 |
|
15644 | 30 |
val axiom_file = File.tmp_path (Path.basic "axioms"); |
31 |
val hyps_file = File.tmp_path (Path.basic "hyps"); |
|
32 |
val prob_file = File.tmp_path (Path.basic "prob"); |
|
33 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
34 |
|
15347 | 35 |
(**** for Isabelle/ML interface ****) |
36 |
||
16897 | 37 |
(*Remove unwanted characters such as ? and newline from the textural |
38 |
representation of a theorem (surely they don't need to be produced in |
|
39 |
the first place?) *) |
|
15608 | 40 |
|
16897 | 41 |
fun is_proof_char ch = (#" " <= ch andalso ch <= #"~" andalso ch <> #"?"); |
42 |
||
43 |
val proofstring = |
|
44 |
String.translate (fn c => if is_proof_char c then str c else ""); |
|
15608 | 45 |
|
15452 | 46 |
|
15347 | 47 |
(**** For running in Isar ****) |
48 |
||
15608 | 49 |
(* same function as that in res_axioms.ML *) |
50 |
fun repeat_RS thm1 thm2 = |
|
51 |
let val thm1' = thm1 RS thm2 handle THM _ => thm1 |
|
52 |
in |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
53 |
if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2) |
15608 | 54 |
end; |
55 |
||
56 |
(* a special version of repeat_RS *) |
|
57 |
fun repeat_someI_ex thm = repeat_RS thm someI_ex; |
|
58 |
||
16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset
|
59 |
|
15644 | 60 |
(*********************************************************************) |
15608 | 61 |
(* convert clauses from "assume" to conjecture. write to file "hyps" *) |
15644 | 62 |
(* hypotheses of the goal currently being proved *) |
63 |
(*********************************************************************) |
|
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
64 |
(*perhaps have 2 different versions of this, depending on whether or not spass is set *) |
15608 | 65 |
fun isar_atp_h thms = |
66 |
let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms |
|
15644 | 67 |
val prems' = map repeat_someI_ex prems |
68 |
val prems'' = make_clauses prems' |
|
69 |
val prems''' = ResAxioms.rm_Eps [] prems'' |
|
70 |
val clss = map ResClause.make_conjecture_clause prems''' |
|
15774 | 71 |
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) |
15608 | 72 |
val tfree_lits = ResLib.flat_noDup tfree_litss |
16767 | 73 |
(* tfree clause is different in tptp and dfg versions *) |
15608 | 74 |
val tfree_clss = map ResClause.tfree_clause tfree_lits |
16259 | 75 |
val hypsfile = File.platform_path hyps_file |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
76 |
val out = TextIO.openOut(hypsfile) |
15608 | 77 |
in |
16904 | 78 |
ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
79 |
TextIO.closeOut out; debug hypsfile; |
|
80 |
tfree_lits |
|
15608 | 81 |
end; |
15347 | 82 |
|
15644 | 83 |
|
84 |
(*********************************************************************) |
|
85 |
(* write out a subgoal as tptp clauses to the file "probN" *) |
|
86 |
(* where N is the number of this subgoal *) |
|
87 |
(*********************************************************************) |
|
88 |
||
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
89 |
fun tptp_inputs_tfrees thms n tfrees axclauses = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
90 |
let |
16904 | 91 |
val _ = debug ("in tptp_inputs_tfrees 0") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
92 |
val clss = map (ResClause.make_conjecture_clause_thm) thms |
16904 | 93 |
val _ = debug ("in tptp_inputs_tfrees 1") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
94 |
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) |
16904 | 95 |
val _ = debug ("in tptp_inputs_tfrees 2") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
96 |
val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) |
16904 | 97 |
val _ = debug ("in tptp_inputs_tfrees 3") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
98 |
val probfile = File.platform_path prob_file ^ "_" ^ string_of_int n |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
99 |
val out = TextIO.openOut(probfile) |
15608 | 100 |
in |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
101 |
ResLib.writeln_strs out (List.concat (map ResClause.tptp_clause axclauses)); |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
102 |
ResLib.writeln_strs out (tfree_clss @ tptp_clss); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
103 |
TextIO.closeOut out; |
16904 | 104 |
debug probfile |
15608 | 105 |
end; |
15452 | 106 |
|
15608 | 107 |
|
16767 | 108 |
(*********************************************************************) |
109 |
(* write out a subgoal as DFG clauses to the file "probN" *) |
|
110 |
(* where N is the number of this subgoal *) |
|
111 |
(*********************************************************************) |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
112 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
113 |
fun dfg_inputs_tfrees thms n tfrees axclauses = |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
114 |
let val clss = map (ResClause.make_conjecture_clause_thm) thms |
16767 | 115 |
val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n) |
17231 | 116 |
val _ = debug ("about to write out dfg prob file " ^ probfile) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
117 |
(*val (dfg_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2dfg clss) |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
118 |
val tfree_clss = map ResClause.tfree_dfg_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) *) |
17234 | 119 |
val probN = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) |
17231 | 120 |
axclauses [] [] [] tfrees |
16767 | 121 |
val out = TextIO.openOut(probfile) |
122 |
in |
|
17234 | 123 |
(ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) |
17231 | 124 |
(* (ResLib.writeln_strs out (tfree_clss @ dfg_clss); *) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
125 |
end; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
126 |
|
16357 | 127 |
|
15644 | 128 |
(*********************************************************************) |
17306 | 129 |
(* call prover with settings and problem file for the current subgoal *) |
15644 | 130 |
(*********************************************************************) |
16357 | 131 |
(* now passing in list of skolemized thms and list of sgterms to go with them *) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
132 |
fun call_resolve_tac (thms: thm list list) sign (sg_terms: term list) (childin, childout,pid) n = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
133 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
134 |
val axfile = (File.platform_path axiom_file) |
16520 | 135 |
|
136 |
val hypsfile = (File.platform_path hyps_file) |
|
137 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
138 |
fun make_atp_list [] sign n = [] |
16897 | 139 |
| make_atp_list ((sko_thm, sg_term)::xs) sign n = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
140 |
let |
16897 | 141 |
val thmstr = proofstring (Meson.concat_with_and (map string_of_thm sko_thm)) |
16904 | 142 |
val _ = debug ("thmstring in make_atp_lists is " ^ thmstr) |
15608 | 143 |
|
16897 | 144 |
val goalstring = proofstring (Sign.string_of_term sign sg_term) |
16904 | 145 |
val _ = debug ("goalstring in make_atp_lists is " ^ goalstring) |
16357 | 146 |
|
16897 | 147 |
val probfile = File.platform_path prob_file ^ "_" ^ (string_of_int n) |
16904 | 148 |
val _ = debug ("prob file in call_resolve_tac is " ^ probfile) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
149 |
in |
17317
3f12de2e2e6e
Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset
|
150 |
(*Avoid command arguments containing spaces: Poly/ML and SML/NJ |
3f12de2e2e6e
Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset
|
151 |
versions of Unix.execute treat them differently!*) |
17306 | 152 |
if !prover = "spass" |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
153 |
then |
17306 | 154 |
let val optionline = |
155 |
if !SpassComm.reconstruct |
|
156 |
(*Proof reconstruction works for only a limited set of |
|
157 |
inference rules*) |
|
158 |
then "-" ^ space_implode "%-" (!custom_spass) |
|
17317
3f12de2e2e6e
Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset
|
159 |
else "-DocProof%-TimeLimit=60%-SOS%-FullRed=0" (*Auto mode*) |
16904 | 160 |
val _ = debug ("SPASS option string is " ^ optionline) |
16897 | 161 |
val _ = ResLib.helper_path "SPASS_HOME" "SPASS" |
162 |
(*We've checked that SPASS is there for ATP/spassshell to run.*) |
|
163 |
in |
|
164 |
([("spass", thmstr, goalstring, |
|
165 |
getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell", |
|
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
166 |
optionline, axfile, hypsfile, probfile)] @ |
16897 | 167 |
(make_atp_list xs sign (n+1))) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
168 |
end |
17306 | 169 |
else if !prover = "vampire" |
17235
8e55ad29b690
Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents:
17234
diff
changeset
|
170 |
then |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
171 |
let val vampire = ResLib.helper_path "VAMPIRE_HOME" "vkernel" |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
172 |
in |
17317
3f12de2e2e6e
Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset
|
173 |
([("vampire", thmstr, goalstring, vampire, "-t60%-m100000", |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
174 |
axfile, hypsfile, probfile)] @ |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
175 |
(make_atp_list xs sign (n+1))) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
176 |
end |
17306 | 177 |
else if !prover = "E" |
178 |
then |
|
179 |
let val Eprover = ResLib.helper_path "E_HOME" "eproof" |
|
180 |
in |
|
181 |
([("E", thmstr, goalstring, Eprover, |
|
182 |
"--tptp-in%-l5%-xAuto%-tAuto%--soft-cpu-limit=60", |
|
183 |
axfile, hypsfile, probfile)] @ |
|
184 |
(make_atp_list xs sign (n+1))) |
|
185 |
end |
|
186 |
else error ("Invalid prover name: " ^ !prover) |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
187 |
end |
15452 | 188 |
|
16897 | 189 |
val atp_list = make_atp_list (ListPair.zip (thms, sg_terms)) sign 1 |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
190 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
191 |
Watcher.callResProvers(childout,atp_list); |
16904 | 192 |
debug "Sent commands to watcher!"; |
17234 | 193 |
all_tac |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
194 |
end |
16357 | 195 |
|
15644 | 196 |
(**********************************************************) |
197 |
(* write out the current subgoal as a tptp file, probN, *) |
|
17234 | 198 |
(* then call all_tac - should be call_res_tac *) |
15644 | 199 |
(**********************************************************) |
15679
28eb0fe50533
Integrating the reconstruction files into the building of HOL
quigley
parents:
15657
diff
changeset
|
200 |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
201 |
|
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
202 |
fun get_sko_thms tfrees sign sg_terms (childin, childout,pid) thm n sko_thms axclauses = |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
203 |
if n=0 then |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
204 |
(call_resolve_tac (rev sko_thms) |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
205 |
sign sg_terms (childin, childout, pid) (List.length sg_terms); |
17234 | 206 |
all_tac thm) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
207 |
else |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
208 |
|
17306 | 209 |
(SELECT_GOAL |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
210 |
(EVERY1 [rtac ccontr, ResLib.atomize_tac, skolemize_tac, |
17231 | 211 |
METAHYPS(fn negs => |
17306 | 212 |
(if !prover = "spass" |
17231 | 213 |
then dfg_inputs_tfrees (make_clauses negs) n tfrees axclauses |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
214 |
else tptp_inputs_tfrees (make_clauses negs) n tfrees axclauses; |
17231 | 215 |
get_sko_thms tfrees sign sg_terms (childin, childout, pid) |
17306 | 216 |
thm (n-1) (negs::sko_thms) axclauses; |
217 |
all_tac))]) n thm) |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
218 |
|
15644 | 219 |
|
220 |
||
221 |
(**********************************************) |
|
222 |
(* recursively call atp_tac_g on all subgoals *) |
|
223 |
(* sg_term is the nth subgoal as a term - used*) |
|
224 |
(* in proof reconstruction *) |
|
225 |
(**********************************************) |
|
226 |
||
17306 | 227 |
fun isar_atp_aux thms thm n_subgoals (childin, childout, pid) axclauses = |
228 |
let val tfree_lits = isar_atp_h thms |
|
229 |
val prems = Thm.prems_of thm |
|
230 |
val sign = sign_of_thm thm |
|
231 |
val thmstring = string_of_thm thm |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
232 |
in |
17306 | 233 |
debug ("in isar_atp_aux"); |
16904 | 234 |
debug("thmstring in isar_atp_goal': " ^ thmstring); |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
235 |
(* go and call callResProvers with this subgoal *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
236 |
(* isar_atp_g tfree_lits sg_term (childin, childout, pid) k thm; *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
237 |
(* recursive call to pick up the remaining subgoals *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
238 |
(* isar_atp_goal' thm (k+1) n tfree_lits (childin, childout, pid) *) |
17306 | 239 |
get_sko_thms tfree_lits sign prems (childin, childout, pid) |
240 |
thm n_subgoals [] axclauses |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
241 |
end; |
15644 | 242 |
|
243 |
(******************************************************************) |
|
244 |
(* called in Isar automatically *) |
|
245 |
(* writes out the current clasimpset to a tptp file *) |
|
246 |
(* passes all subgoals on to isar_atp_aux for further processing *) |
|
247 |
(* turns off xsymbol at start of function, restoring it at end *) |
|
248 |
(******************************************************************) |
|
15779
aed221aff642
Removed remaining references to Main.thy in reconstruction code.
quigley
parents:
15774
diff
changeset
|
249 |
(*FIX changed to clasimp_file *) |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
250 |
val isar_atp' = setmp print_mode [] (fn (ctxt, thms, thm) => |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
251 |
if Thm.no_prems thm then () |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
252 |
else |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
253 |
let |
16904 | 254 |
val _= debug ("in isar_atp'") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
255 |
val thy = ProofContext.theory_of ctxt |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
256 |
val prems = Thm.prems_of thm |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
257 |
val thms_string = Meson.concat_with_and (map string_of_thm thms) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
258 |
val prems_string = Meson.concat_with_and (map (Sign.string_of_term thy) prems) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
259 |
|
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
260 |
(*set up variables for writing out the clasimps to a tptp file*) |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
261 |
val (clause_arr, num_of_clauses, axclauses) = |
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
262 |
ResClasimp.get_clasimp_lemmas thy (hd prems) (*FIXME: hack!! need to do all prems*) |
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset
|
263 |
val _ = debug ("claset and simprules total " ^ (string_of_int num_of_clauses)^ " clauses") |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
264 |
val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr, num_of_clauses) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
265 |
val pid_string = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
266 |
string_of_int (Word.toInt (Word.fromLargeWord (Posix.Process.pidToWord pid))) |
15608 | 267 |
in |
16904 | 268 |
debug ("initial thms: " ^ thms_string); |
269 |
debug ("subgoals: " ^ prems_string); |
|
270 |
debug ("pid: "^ pid_string); |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
271 |
isar_atp_aux thms thm (length prems) (childin, childout, pid) axclauses; |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
272 |
() |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
273 |
end); |
15608 | 274 |
|
15452 | 275 |
|
15608 | 276 |
fun get_thms_cs claset = |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
277 |
let val {safeEs, safeIs, hazEs, hazIs, ...} = rep_cs claset |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
278 |
in safeEs @ safeIs @ hazEs @ hazIs end; |
16357 | 279 |
|
15608 | 280 |
fun append_name name [] _ = [] |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
281 |
| append_name name (thm :: thms) k = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
282 |
Thm.name_thm ((name ^ "_" ^ string_of_int k), thm) :: append_name name thms (k + 1); |
15608 | 283 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
284 |
fun append_names (name :: names) (thms :: thmss) = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
285 |
append_name name thms 0 :: append_names names thmss; |
16357 | 286 |
|
15608 | 287 |
fun get_thms_ss [] = [] |
288 |
| get_thms_ss thms = |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
289 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
290 |
val names = map Thm.name_of_thm thms |
15608 | 291 |
val thms' = map (mksimps mksimps_pairs) thms |
292 |
val thms'' = append_names names thms' |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
293 |
in |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
294 |
ResLib.flat_noDup thms'' |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
295 |
end; |
15608 | 296 |
|
15452 | 297 |
|
15608 | 298 |
(* convert locally declared rules to axiom clauses *) |
299 |
||
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
300 |
fun subtract_simpset thy ctxt = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
301 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
302 |
val rules1 = #rules (#1 (rep_ss (simpset_of thy))); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
303 |
val rules2 = #rules (#1 (rep_ss (local_simpset_of ctxt))); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
304 |
in map #thm (Net.subtract MetaSimplifier.eq_rrule rules1 rules2) end; |
15679
28eb0fe50533
Integrating the reconstruction files into the building of HOL
quigley
parents:
15657
diff
changeset
|
305 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
306 |
fun subtract_claset thy ctxt = |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
307 |
let |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
308 |
val (netI1, netE1) = #xtra_netpair (rep_cs (claset_of thy)); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
309 |
val (netI2, netE2) = #xtra_netpair (rep_cs (local_claset_of ctxt)); |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
310 |
val subtract = map (#2 o #2) oo Net.subtract Tactic.eq_kbrl; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
311 |
in subtract netI1 netI2 @ subtract netE1 netE2 end; |
15608 | 312 |
|
313 |
||
16357 | 314 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
315 |
(** the Isar toplevel hook **) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
316 |
|
17091 | 317 |
val invoke_atp = Toplevel.unknown_proof o Toplevel.keep (fn state => |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
318 |
let |
17091 | 319 |
val proof = Toplevel.proof_of state |
320 |
val (ctxt, (_, goal)) = Proof.get_goal proof |
|
321 |
handle Proof.STATE _ => error "No goal present"; |
|
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
322 |
|
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
323 |
val thy = ProofContext.theory_of ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
324 |
|
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
325 |
(* FIXME presently unused *) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
326 |
val ss_thms = subtract_simpset thy ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
327 |
val cs_thms = subtract_claset thy ctxt; |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
328 |
in |
17091 | 329 |
debug ("initial thm in isar_atp: " ^ |
330 |
Pretty.string_of (ProofContext.pretty_thm ctxt goal)); |
|
331 |
debug ("subgoals in isar_atp: " ^ |
|
332 |
Pretty.string_of (ProofContext.pretty_term ctxt |
|
333 |
(Logic.mk_conjunction_list (Thm.prems_of goal)))); |
|
16904 | 334 |
debug ("number of subgoals in isar_atp: " ^ string_of_int (Thm.nprems_of goal)); |
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
335 |
hook_count := !hook_count +1; |
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset
|
336 |
debug ("in hook for time: " ^(string_of_int (!hook_count)) ); |
16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset
|
337 |
ResClause.init thy; |
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
338 |
isar_atp' (ctxt, ProofContext.prems_of ctxt, goal) |
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset
|
339 |
end); |
16357 | 340 |
|
17091 | 341 |
val call_atpP = |
342 |
OuterSyntax.improper_command |
|
343 |
"ProofGeneral.call_atp" |
|
344 |
"call automatic theorem provers" |
|
345 |
OuterKeyword.diag |
|
346 |
(Scan.succeed (Toplevel.no_timing o invoke_atp)); |
|
347 |
||
348 |
val _ = OuterSyntax.add_parsers [call_atpP]; |
|
349 |
||
15347 | 350 |
end; |