author  paulson 
Mon, 19 Sep 2005 18:30:22 +0200  
changeset 17488  67376a311a2b 
parent 17484  f6a225f97f0a 
child 17502  8836793df947 
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 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

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

13 
val hook_count: int ref 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

14 
val problem_name: string ref 
15347  15 
end; 
16 

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

17 
structure ResAtp: RES_ATP = 
15347  18 
struct 
19 

17150
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 

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

23 
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

24 
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

25 
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

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

17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

28 
val destdir = ref ""; (*Empty means write files to /tmp*) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

29 
val problem_name = ref "prob"; 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

30 

f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

31 
fun prob_pathname() = 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

32 
if !destdir = "" then File.platform_path (File.tmp_path (Path.basic (!problem_name))) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

33 
else if File.exists (File.unpack_platform_path (!destdir)) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

34 
then !destdir ^ "/" ^ !problem_name 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

35 
else error ("No such directory: " ^ !destdir); 
15644  36 

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

37 

15347  38 
(**** for Isabelle/ML interface ****) 
39 

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

42 
the first place?) *) 

15608  43 

16897  44 
fun is_proof_char ch = (#" " <= ch andalso ch <= #"~" andalso ch <> #"?"); 
45 

46 
val proofstring = 

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

15608  48 

15452  49 

15347  50 
(**** For running in Isar ****) 
51 

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

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

55 
in 

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

56 
if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2) 
15608  57 
end; 
58 

59 
(* a special version of repeat_RS *) 

60 
fun repeat_someI_ex thm = repeat_RS thm someI_ex; 

61 

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

62 

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

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

66 
(*********************************************************************) 

67 

17422  68 
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

69 
let 
16904  70 
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

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

73 
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) 
16904  74 
val _ = debug ("in tptp_inputs_tfrees 2") 
17422  75 
val tfree_clss = map ResClause.tfree_clause (ResLib.flat_noDup tfree_litss) 
16904  76 
val _ = debug ("in tptp_inputs_tfrees 3") 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

77 
val probfile = prob_pathname() ^ "_" ^ string_of_int n 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

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

80 
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

81 
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

82 
TextIO.closeOut out; 
16904  83 
debug probfile 
15608  84 
end; 
15452  85 

15608  86 

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

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

90 
(*********************************************************************) 

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

91 

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

93 
let val clss = map (ResClause.make_conjecture_clause_thm) thms 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

94 
val probfile = prob_pathname() ^ "_" ^ (string_of_int n) 
17231  95 
val _ = debug ("about to write out dfg prob file " ^ probfile) 
17234  96 
val probN = ResClause.clauses2dfg clss ("prob" ^ (string_of_int n)) 
17422  97 
axclauses [] [] [] 
16767  98 
val out = TextIO.openOut(probfile) 
99 
in 

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

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

103 

16357  104 

15644  105 
(*********************************************************************) 
17306  106 
(* call prover with settings and problem file for the current subgoal *) 
15644  107 
(*********************************************************************) 
16357  108 
(* now passing in list of skolemized thms and list of sgterms to go with them *) 
17422  109 
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

110 
let 
17422  111 
fun make_atp_list [] n = [] 
112 
 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

113 
let 
16897  114 
val goalstring = proofstring (Sign.string_of_term sign sg_term) 
16904  115 
val _ = debug ("goalstring in make_atp_lists is " ^ goalstring) 
16357  116 

17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

117 
val probfile = prob_pathname() ^ "_" ^ string_of_int n 
17422  118 
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

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

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

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

123 
then 
17306  124 
let val optionline = 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

125 
if !AtpCommunication.reconstruct 
17306  126 
(*Proof reconstruction works for only a limited set of 
127 
inference rules*) 

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

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

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

133 
in 

17422  134 
([("spass", goalstring, 
16897  135 
getenv "ISABELLE_HOME" ^ "/src/HOL/Tools/ATP/spassshell", 
17422  136 
optionline, probfile)] @ 
137 
(make_atp_list xs (n+1))) 

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

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

140 
then 
17435  141 
let val vampire = ResLib.helper_path "VAMPIRE_HOME" "vampire" 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

142 
in 
17435  143 
([("vampire", goalstring, vampire, "t 60%m 100000", probfile)] @ 
144 
(make_atp_list xs (n+1))) (*BEWARE! spaces in options!*) 

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

145 
end 
17306  146 
else if !prover = "E" 
147 
then 

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

149 
in 

17422  150 
([("E", goalstring, Eprover, 
17306  151 
"tptpin%l5%xAuto%tAuto%softcpulimit=60", 
17422  152 
probfile)] @ 
153 
(make_atp_list xs (n+1))) 

17306  154 
end 
155 
else error ("Invalid prover name: " ^ !prover) 

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

156 
end 
15452  157 

17422  158 
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

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

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

162 
end 
16357  163 

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

166 
if n=0 then () 

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

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

169 
(EVERY1 [rtac ccontr, ResLib.atomize_tac, skolemize_tac, 
17231  170 
METAHYPS(fn negs => 
17306  171 
(if !prover = "spass" 
17422  172 
then dfg_inputs_tfrees (make_clauses negs) n axclauses 
173 
else tptp_inputs_tfrees (make_clauses negs) n axclauses; 

174 
write_problem_files axclauses thm (n1); 

175 
all_tac))]) n thm; 

176 
()); 

15644  177 

178 

17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

179 
(*FIXME: WHAT IS THMS FOR????*) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

180 

15644  181 
(******************************************************************) 
182 
(* called in Isar automatically *) 

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

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

185 
(******************************************************************) 

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

186 
(*FIX changed to clasimp_file *) 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

187 
val isar_atp = setmp print_mode [] 
17422  188 
(fn (ctxt, thms, thm) => 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

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

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

191 
let 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

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

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

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

195 
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

196 
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

197 

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

198 
(*set up variables for writing out the clasimps to a tptp file*) 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

199 
val (clause_arr, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

200 
(*FIXME: hack!! need to consider relevance for all prems*) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

201 
val _ = debug ("claset and simprules total clauses = " ^ 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

202 
string_of_int (Array.length clause_arr)) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

203 
val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr) 
15608  204 
in 
16904  205 
debug ("initial thms: " ^ thms_string); 
206 
debug ("subgoals: " ^ prems_string); 

17488
67376a311a2b
further simplification of the IsabelleATP linkup
paulson
parents:
17484
diff
changeset

207 
debug ("pid: " ^ Int.toString (ResLib.intOfPid pid)); 
17422  208 
write_problem_files axclauses thm (length prems); 
209 
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

210 
end); 
15608  211 

17422  212 
val isar_atp_writeonly = setmp print_mode [] 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

213 
(fn (ctxt, thms: thm list, thm) => 
17422  214 
if Thm.no_prems thm then () 
215 
else 

17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

216 
let val prems = Thm.prems_of thm 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

217 
val (_, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) 
17422  218 
in 
219 
write_problem_files axclauses thm (length prems) 

220 
end); 

15452  221 

16357  222 

17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

223 
(* convert locally declared rules to axiom clauses: UNUSED *) 
15608  224 

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

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

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

227 
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

228 
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

229 
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

230 

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

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

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

233 
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

234 
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

235 
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

236 
in subtract netI1 netI2 @ subtract netE1 netE2 end; 
15608  237 

238 

16357  239 

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

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

241 

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

243 
let 
17091  244 
val proof = Toplevel.proof_of state 
245 
val (ctxt, (_, goal)) = Proof.get_goal proof 

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

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

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

248 
in 
17091  249 
debug ("initial thm in isar_atp: " ^ 
250 
Pretty.string_of (ProofContext.pretty_thm ctxt goal)); 

251 
debug ("subgoals in isar_atp: " ^ 

252 
Pretty.string_of (ProofContext.pretty_term ctxt 

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

16904  254 
debug ("number of subgoals in isar_atp: " ^ string_of_int (Thm.nprems_of goal)); 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

255 
debug ("current theory: " ^ Context.theory_name thy); 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

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

257 
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

258 
ResClause.init thy; 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

259 
if !destdir = "" then isar_atp (ctxt, ProofContext.prems_of ctxt, goal) 
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

260 
else isar_atp_writeonly (ctxt, ProofContext.prems_of ctxt, goal) 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

261 
end); 
16357  262 

17091  263 
val call_atpP = 
264 
OuterSyntax.improper_command 

265 
"ProofGeneral.call_atp" 

266 
"call automatic theorem provers" 

267 
OuterKeyword.diag 

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

269 

270 
val _ = OuterSyntax.add_parsers [call_atpP]; 

271 

15347  272 
end; 