author  paulson 
Thu, 15 Sep 2005 17:46:00 +0200  
changeset 17422  3b237822985d 
parent 17404  d16c3a62c396 
child 17435  0eed5a1c00c1 
permissions  rwrr 
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 
17306  10 
val prover: string ref 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

11 
val custom_spass: string list ref 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

12 
val hook_count: int ref 
15347  13 
end; 
14 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

15 
structure ResAtp: RES_ATP = 
15347  16 
struct 
17 

17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

18 

ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

19 
val call_atp = ref false; 
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

20 
val hook_count = ref 0; 
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

21 

16904  22 
fun debug_tac tac = (debug "testing"; tac); 
16478  23 

17404
d16c3a62c396
the experimental tagging system, and the usual tidying
paulson
parents:
17317
diff
changeset

24 
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

25 
val custom_spass = (*specialized options for SPASS*) 
17317
3f12de2e2e6e
IsabelleATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset

26 
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

27 
"DocProof","TimeLimit=60"]; 
15347  28 

15644  29 
val prob_file = File.tmp_path (Path.basic "prob"); 
30 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

31 

15347  32 
(**** for Isabelle/ML interface ****) 
33 

16897  34 
(*Remove unwanted characters such as ? and newline from the textural 
35 
representation of a theorem (surely they don't need to be produced in 

36 
the first place?) *) 

15608  37 

16897  38 
fun is_proof_char ch = (#" " <= ch andalso ch <= #"~" andalso ch <> #"?"); 
39 

40 
val proofstring = 

41 
String.translate (fn c => if is_proof_char c then str c else ""); 

15608  42 

15452  43 

15347  44 
(**** For running in Isar ****) 
45 

15608  46 
(* same function as that in res_axioms.ML *) 
47 
fun repeat_RS thm1 thm2 = 

48 
let val thm1' = thm1 RS thm2 handle THM _ => thm1 

49 
in 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

50 
if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2) 
15608  51 
end; 
52 

53 
(* a special version of repeat_RS *) 

54 
fun repeat_someI_ex thm = repeat_RS thm someI_ex; 

55 

16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset

56 

15644  57 
(*********************************************************************) 
58 
(* write out a subgoal as tptp clauses to the file "probN" *) 

59 
(* where N is the number of this subgoal *) 

60 
(*********************************************************************) 

61 

17422  62 
fun tptp_inputs_tfrees thms n axclauses = 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

63 
let 
16904  64 
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

65 
val clss = map (ResClause.make_conjecture_clause_thm) thms 
16904  66 
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

67 
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) 
16904  68 
val _ = debug ("in tptp_inputs_tfrees 2") 
17422  69 
val tfree_clss = map ResClause.tfree_clause (ResLib.flat_noDup tfree_litss) 
16904  70 
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

71 
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

72 
val out = TextIO.openOut(probfile) 
15608  73 
in 
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset

74 
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

75 
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

76 
TextIO.closeOut out; 
16904  77 
debug probfile 
15608  78 
end; 
15452  79 

15608  80 

16767  81 
(*********************************************************************) 
82 
(* write out a subgoal as DFG clauses to the file "probN" *) 

83 
(* where N is the number of this subgoal *) 

84 
(*********************************************************************) 

17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

85 

17422  86 
fun dfg_inputs_tfrees thms n axclauses = 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

87 
let val clss = map (ResClause.make_conjecture_clause_thm) thms 
16767  88 
val probfile = (File.platform_path prob_file) ^ "_" ^ (string_of_int n) 
17231  89 
val _ = debug ("about to write out dfg prob file " ^ probfile) 
17234  90 
val probN = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) 
17422  91 
axclauses [] [] [] 
16767  92 
val out = TextIO.openOut(probfile) 
93 
in 

17234  94 
(ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) 
17231  95 
(* (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

96 
end; 
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

97 

16357  98 

15644  99 
(*********************************************************************) 
17306  100 
(* call prover with settings and problem file for the current subgoal *) 
15644  101 
(*********************************************************************) 
16357  102 
(* now passing in list of skolemized thms and list of sgterms to go with them *) 
17422  103 
fun watcher_call_provers sign sg_terms (childin, childout,pid) = 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

104 
let 
17422  105 
fun make_atp_list [] n = [] 
106 
 make_atp_list ((sg_term)::xs) n = 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

107 
let 
16897  108 
val goalstring = proofstring (Sign.string_of_term sign sg_term) 
16904  109 
val _ = debug ("goalstring in make_atp_lists is " ^ goalstring) 
16357  110 

16897  111 
val probfile = File.platform_path prob_file ^ "_" ^ (string_of_int n) 
17422  112 
val _ = debug ("prob file in watcher_call_provers is " ^ probfile) 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

113 
in 
17317
3f12de2e2e6e
IsabelleATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset

114 
(*Avoid command arguments containing spaces: Poly/ML and SML/NJ 
3f12de2e2e6e
IsabelleATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset

115 
versions of Unix.execute treat them differently!*) 
17306  116 
if !prover = "spass" 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

117 
then 
17306  118 
let val optionline = 
119 
if !SpassComm.reconstruct 

120 
(*Proof reconstruction works for only a limited set of 

121 
inference rules*) 

122 
then "" ^ space_implode "%" (!custom_spass) 

17317
3f12de2e2e6e
IsabelleATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents:
17306
diff
changeset

123 
else "DocProof%TimeLimit=60%SOS%FullRed=0" (*Auto mode*) 
16904  124 
val _ = debug ("SPASS option string is " ^ optionline) 
16897  125 
val _ = ResLib.helper_path "SPASS_HOME" "SPASS" 
126 
(*We've checked that SPASS is there for ATP/spassshell to run.*) 

127 
in 

17422  128 
([("spass", goalstring, 
16897  129 
getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell", 
17422  130 
optionline, probfile)] @ 
131 
(make_atp_list xs (n+1))) 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

132 
end 
17306  133 
else if !prover = "vampire" 
17235
8e55ad29b690
Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents:
17234
diff
changeset

134 
then 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

135 
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

136 
in 
17422  137 
([("vampire", goalstring, vampire, "t60%m100000", 
138 
probfile)] @ 

139 
(make_atp_list xs (n+1))) 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

140 
end 
17306  141 
else if !prover = "E" 
142 
then 

143 
let val Eprover = ResLib.helper_path "E_HOME" "eproof" 

144 
in 

17422  145 
([("E", goalstring, Eprover, 
17306  146 
"tptpin%l5%xAuto%tAuto%softcpulimit=60", 
17422  147 
probfile)] @ 
148 
(make_atp_list xs (n+1))) 

17306  149 
end 
150 
else error ("Invalid prover name: " ^ !prover) 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

151 
end 
15452  152 

17422  153 
val atp_list = make_atp_list sg_terms 1 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

154 
in 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

155 
Watcher.callResProvers(childout,atp_list); 
17422  156 
debug "Sent commands to watcher!" 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

157 
end 
16357  158 

17422  159 
(*We write out problem files for each subgoal, but work is repeated (skolemize)*) 
160 
fun write_problem_files axclauses thm n = 

161 
if n=0 then () 

17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

162 
else 
17422  163 
(SELECT_GOAL 
17305
6cef3aedd661
axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents:
17235
diff
changeset

164 
(EVERY1 [rtac ccontr, ResLib.atomize_tac, skolemize_tac, 
17231  165 
METAHYPS(fn negs => 
17306  166 
(if !prover = "spass" 
17422  167 
then dfg_inputs_tfrees (make_clauses negs) n axclauses 
168 
else tptp_inputs_tfrees (make_clauses negs) n axclauses; 

169 
write_problem_files axclauses thm (n1); 

170 
all_tac))]) n thm; 

171 
()); 

15644  172 

173 

174 
(******************************************************************) 

175 
(* called in Isar automatically *) 

176 
(* writes out the current clasimpset to a tptp file *) 

177 
(* turns off xsymbol at start of function, restoring it at end *) 

178 
(******************************************************************) 

15779
aed221aff642
Removed remaining references to Main.thy in reconstruction code.
quigley
parents:
15774
diff
changeset

179 
(*FIX changed to clasimp_file *) 
17422  180 
val isar_atp' = setmp print_mode [] 
181 
(fn (ctxt, thms, thm) => 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

182 
if Thm.no_prems thm then () 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

183 
else 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

184 
let 
16904  185 
val _= debug ("in isar_atp'") 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

186 
val thy = ProofContext.theory_of ctxt 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

187 
val prems = Thm.prems_of thm 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

188 
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

189 
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

190 

6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

191 
(*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

192 
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

193 
ResClasimp.get_clasimp_lemmas thy (hd prems) (*FIXME: hack!! need to do all prems*) 
17422  194 
val _ = debug ("claset and simprules total " ^ (string_of_int num_of_clauses)^ 
195 
" clauses") 

196 
val (childin, childout, pid) = 

197 
Watcher.createWatcher (thm, clause_arr, num_of_clauses) 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

198 
val pid_string = 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

199 
string_of_int (Word.toInt (Word.fromLargeWord (Posix.Process.pidToWord pid))) 
15608  200 
in 
16904  201 
debug ("initial thms: " ^ thms_string); 
202 
debug ("subgoals: " ^ prems_string); 

203 
debug ("pid: "^ pid_string); 

17422  204 
write_problem_files axclauses thm (length prems); 
205 
watcher_call_provers (sign_of_thm thm) (Thm.prems_of thm) (childin, childout, pid) 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

206 
end); 
15608  207 

17422  208 
val isar_atp_writeonly = setmp print_mode [] 
209 
(fn (ctxt, thms, thm) => 

210 
if Thm.no_prems thm then () 

211 
else 

212 
let 

213 
val thy = ProofContext.theory_of ctxt 

214 
val prems = Thm.prems_of thm 

215 

216 
(*set up variables for writing out the clasimps to a tptp file*) 

217 
val (clause_arr, num_of_clauses, axclauses) = 

218 
ResClasimp.get_clasimp_lemmas thy (hd prems) (*FIXME: hack!! need to do all prems*) 

219 
in 

220 
write_problem_files axclauses thm (length prems) 

221 
end); 

15452  222 

15608  223 
fun get_thms_cs claset = 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

224 
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

225 
in safeEs @ safeIs @ hazEs @ hazIs end; 
16357  226 

15608  227 
fun append_name name [] _ = [] 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

228 
 append_name name (thm :: thms) k = 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

229 
Thm.name_thm ((name ^ "_" ^ string_of_int k), thm) :: append_name name thms (k + 1); 
15608  230 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

231 
fun append_names (name :: names) (thms :: thmss) = 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

232 
append_name name thms 0 :: append_names names thmss; 
16357  233 

15608  234 
fun get_thms_ss [] = [] 
235 
 get_thms_ss thms = 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

236 
let 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

237 
val names = map Thm.name_of_thm thms 
15608  238 
val thms' = map (mksimps mksimps_pairs) thms 
239 
val thms'' = append_names names thms' 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

240 
in 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

241 
ResLib.flat_noDup thms'' 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

242 
end; 
15608  243 

15452  244 

15608  245 
(* convert locally declared rules to axiom clauses *) 
246 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

247 
fun subtract_simpset thy ctxt = 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

248 
let 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

249 
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

250 
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

251 
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

252 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

253 
fun subtract_claset thy ctxt = 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

254 
let 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

255 
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

256 
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

257 
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

258 
in subtract netI1 netI2 @ subtract netE1 netE2 end; 
15608  259 

260 

16357  261 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

262 
(** the Isar toplevel hook **) 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

263 

17091  264 
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

265 
let 
17091  266 
val proof = Toplevel.proof_of state 
267 
val (ctxt, (_, goal)) = Proof.get_goal proof 

268 
handle Proof.STATE _ => error "No goal present"; 

17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

269 

16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

270 
val thy = ProofContext.theory_of ctxt; 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

271 

6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

272 
(* FIXME presently unused *) 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

273 
val ss_thms = subtract_simpset thy ctxt; 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

274 
val cs_thms = subtract_claset thy ctxt; 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

275 
in 
17091  276 
debug ("initial thm in isar_atp: " ^ 
277 
Pretty.string_of (ProofContext.pretty_thm ctxt goal)); 

278 
debug ("subgoals in isar_atp: " ^ 

279 
Pretty.string_of (ProofContext.pretty_term ctxt 

280 
(Logic.mk_conjunction_list (Thm.prems_of goal)))); 

16904  281 
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

282 
hook_count := !hook_count +1; 
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

283 
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

284 
ResClause.init thy; 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

285 
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

286 
end); 
16357  287 

17091  288 
val call_atpP = 
289 
OuterSyntax.improper_command 

290 
"ProofGeneral.call_atp" 

291 
"call automatic theorem provers" 

292 
OuterKeyword.diag 

293 
(Scan.succeed (Toplevel.no_timing o invoke_atp)); 

294 

295 
val _ = OuterSyntax.add_parsers [call_atpP]; 

296 

15347  297 
end; 