author  paulson 
Wed, 28 Sep 2005 11:16:27 +0200  
changeset 17690  8ba7c3cd24a8 
parent 17525  ae5bb6001afb 
child 17717  7c6a96cbc966 
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 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

15 
val time_limit: int ref 
15347  16 
end; 
17 

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

18 
structure ResAtp: RES_ATP = 
15347  19 
struct 
20 

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

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

22 
val hook_count = ref 0; 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

23 
val time_limit = ref 60; 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

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*) 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

27 
ref ["Auto=0","FullRed=0","IORe","IOFc","RTaut","RFSub","RBSub"]; 
15347  28 

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

29 
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

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

31 

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

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

33 
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

34 
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

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

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

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

38 

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

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

43 
the first place?) *) 

15608  44 

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

47 
val proofstring = 

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

15608  49 

15452  50 

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

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

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

56 
in 

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

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

60 
(* a special version of repeat_RS *) 

61 
fun repeat_someI_ex thm = repeat_RS thm someI_ex; 

62 

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

63 

17502  64 
(* write out a subgoal as tptp clauses to the file "xxxx_N"*) 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

65 
fun tptp_inputs_tfrees thms n (axclauses,classrel_clauses,arity_clauses) = 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

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

67 
val clss = map (ResClause.make_conjecture_clause_thm) thms 
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

68 
val (tptp_clss,tfree_litss) = ListPair.unzip (map ResClause.clause2tptp clss) 
17422  69 
val tfree_clss = map ResClause.tfree_clause (ResLib.flat_noDup tfree_litss) 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

70 
val classrel_cls = map ResClause.tptp_classrelClause classrel_clauses 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

71 
val arity_cls = map ResClause.tptp_arity_clause arity_clauses 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

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

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

75 
ResLib.writeln_strs out (List.concat (map ResClause.tptp_clause axclauses)); 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

76 
ResLib.writeln_strs out (tfree_clss @ tptp_clss @ classrel_cls @ arity_cls); 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

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

17502  81 
(* write out a subgoal in DFG format to the file "xxxx_N"*) 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

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

83 
let val clss = map (ResClause.make_conjecture_clause_thm) thms 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

84 
val probfile = prob_pathname() ^ "_" ^ (Int.toString n) 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

85 
(*FIXME: classrel_clauses and arity_clauses*) 
17231  86 
val _ = debug ("about to write out dfg prob file " ^ probfile) 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

87 
val probN = ResClause.clauses2dfg clss (!problem_name ^ "_" ^ Int.toString n) 
17422  88 
axclauses [] [] [] 
16767  89 
val out = TextIO.openOut(probfile) 
90 
in 

17234  91 
(ResLib.writeln_strs out [probN]; TextIO.closeOut out; debug probfile ) 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

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

93 

16357  94 

15644  95 
(*********************************************************************) 
17306  96 
(* call prover with settings and problem file for the current subgoal *) 
15644  97 
(*********************************************************************) 
16357  98 
(* now passing in list of skolemized thms and list of sgterms to go with them *) 
17422  99 
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

100 
let 
17422  101 
fun make_atp_list [] n = [] 
102 
 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

103 
let 
16897  104 
val goalstring = proofstring (Sign.string_of_term sign sg_term) 
16904  105 
val _ = debug ("goalstring in make_atp_lists is " ^ goalstring) 
16357  106 

17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

107 
val probfile = prob_pathname() ^ "_" ^ Int.toString n 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

108 
val time = Int.toString (!time_limit) 
17502  109 
val _ = debug ("problem 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

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

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

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

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

116 
if !AtpCommunication.reconstruct 
17306  117 
(*Proof reconstruction works for only a limited set of 
118 
inference rules*) 

17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

119 
then space_implode "%" (!custom_spass) ^ 
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

120 
"%DocProof%TimeLimit=" ^ time 
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

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

125 
in 

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

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

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

132 
then 
17435  133 
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

134 
in 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

135 
([("vampire", goalstring, vampire, "m 100000%t " ^ time, probfile)] @ 
17435  136 
(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

137 
end 
17306  138 
else if !prover = "E" 
139 
then 

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

141 
in 

17422  142 
([("E", goalstring, Eprover, 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

143 
"tptpin%l5%xAuto%tAuto%cpulimit=" ^ time, 
17422  144 
probfile)] @ 
145 
(make_atp_list xs (n+1))) 

17306  146 
end 
147 
else error ("Invalid prover name: " ^ !prover) 

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

148 
end 
15452  149 

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

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

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

154 
end 
16357  155 

17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

156 
(*We write out problem files for each subgoal*) 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

157 
fun write_problem_files clause thm n = 
17422  158 
if n=0 then () 
17150
ce2a1aeb42aa
DFG output now works for untyped rules (ML "ResClause.untyped();")
quigley
parents:
17091
diff
changeset

159 
else 
17422  160 
(SELECT_GOAL 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

161 
(EVERY1 [rtac ccontr, ObjectLogic.atomize_tac, skolemize_tac, 
17231  162 
METAHYPS(fn negs => 
17306  163 
(if !prover = "spass" 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

164 
then dfg_inputs_tfrees (make_clauses negs) n clause 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

165 
else tptp_inputs_tfrees (make_clauses negs) n clause; 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

166 
write_problem_files clause thm (n1); 
17422  167 
all_tac))]) n thm; 
168 
()); 

15644  169 

17502  170 
val last_watcher_pid = ref (NONE : Posix.Process.pid option); 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

171 

17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

172 

ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

173 
(*writes out the current clasimpset to a tptp file; 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

174 
turns off xsymbol at start of function, restoring it at end *) 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

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

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

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

179 
let 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

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

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

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

183 
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

184 

17502  185 
val _ = (case !last_watcher_pid of NONE => () 
186 
 SOME pid => (*FIXME: should kill ATP processes too; at least they time out*) 

187 
(debug ("Killing old watcher, pid = " ^ 

188 
Int.toString (ResLib.intOfPid pid)); 

189 
Watcher.killWatcher pid)) 

190 
handle OS.SysErr _ => debug "Attempt to kill watcher failed"; 

16802
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*) 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

192 
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

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

194 
val _ = debug ("claset and simprules total clauses = " ^ 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

195 
Int.toString (Array.length clause_arr)) 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

196 
val classrel_clauses = ResTypesSorts.classrel_clauses_thy thy 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

197 
val _ = debug ("classrel clauses = " ^ Int.toString (length classrel_clauses)) 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

198 
val arity_clauses = ResTypesSorts.arity_clause_thy thy 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

199 
val _ = debug ("arity clauses = " ^ Int.toString (length arity_clauses)) 
17484
f6a225f97f0a
simplification of the IsabelleATP code; hooks for batch generation of problems
paulson
parents:
17435
diff
changeset

200 
val (childin, childout, pid) = Watcher.createWatcher (thm, clause_arr) 
15608  201 
in 
17502  202 
last_watcher_pid := SOME pid; 
16904  203 
debug ("subgoals: " ^ prems_string); 
17488
67376a311a2b
further simplification of the IsabelleATP linkup
paulson
parents:
17484
diff
changeset

204 
debug ("pid: " ^ Int.toString (ResLib.intOfPid pid)); 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

205 
write_problem_files (axclauses,classrel_clauses,arity_clauses) thm (length prems); 
17422  206 
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

207 
end); 
15608  208 

17422  209 
val isar_atp_writeonly = setmp print_mode [] 
17502  210 
(fn (ctxt, thm) => 
17422  211 
if Thm.no_prems thm then () 
212 
else 

17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

213 
let 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

214 
val prems = Thm.prems_of thm 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

215 
val (_, axclauses) = ResClasimp.get_clasimp_lemmas ctxt (hd prems) 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

216 
val thy = ProofContext.theory_of ctxt 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

217 
val classrel_clauses = ResTypesSorts.classrel_clauses_thy thy 
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

218 
val arity_clauses = ResTypesSorts.arity_clause_thy thy 
17422  219 
in 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

220 
write_problem_files (axclauses,classrel_clauses,arity_clauses) thm (length prems) 
17422  221 
end); 
15452  222 

16357  223 

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

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

225 

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

227 
let 
17091  228 
val proof = Toplevel.proof_of state 
229 
val (ctxt, (_, goal)) = Proof.get_goal proof 

230 
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

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

232 
in 
17091  233 
debug ("initial thm in isar_atp: " ^ 
234 
Pretty.string_of (ProofContext.pretty_thm ctxt goal)); 

235 
debug ("subgoals in isar_atp: " ^ 

236 
Pretty.string_of (ProofContext.pretty_term ctxt 

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

17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

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

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

240 
hook_count := !hook_count +1; 
17525
ae5bb6001afb
tidying, and support for axclass/classrel clauses
paulson
parents:
17502
diff
changeset

241 
debug ("in hook for time: " ^(Int.toString (!hook_count)) ); 
16925
0fd7b1438d28
simpler variable names, and no types for monomorphic constants
paulson
parents:
16904
diff
changeset

242 
ResClause.init thy; 
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17525
diff
changeset

243 
if !destdir = "" andalso !time_limit > 0 then isar_atp (ctxt, goal) 
17502  244 
else isar_atp_writeonly (ctxt, goal) 
16802
6eeee59dac4c
use Toplevel.print_state_hook instead of adhoc Proof.atp_hook;
wenzelm
parents:
16767
diff
changeset

245 
end); 
16357  246 

17091  247 
val call_atpP = 
248 
OuterSyntax.improper_command 

249 
"ProofGeneral.call_atp" 

250 
"call automatic theorem provers" 

251 
OuterKeyword.diag 

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

253 

254 
val _ = OuterSyntax.add_parsers [call_atpP]; 

255 

15347  256 
end; 