author | paulson |
Fri, 24 Jun 2005 16:18:41 +0200 | |
changeset 16561 | 2bc33f0cfe9a |
parent 16548 | aa36ae6b955e |
child 16675 | 96bdc59afc05 |
permissions | -rw-r--r-- |
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
1 |
(* Title: Watcher.ML |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16100
diff
changeset
|
2 |
|
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
3 |
ID: $Id$ |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
4 |
Author: Claire Quigley |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
5 |
Copyright 2004 University of Cambridge |
15642 | 6 |
*) |
7 |
||
8 |
(***************************************************************************) |
|
9 |
(* The watcher process starts a resolution process when it receives a *) |
|
10 |
(* message from Isabelle *) |
|
11 |
(* Signals Isabelle, puts output of child into pipe to Isabelle, *) |
|
12 |
(* and removes dead processes. Also possible to kill all the resolution *) |
|
13 |
(* processes currently running. *) |
|
14 |
(* Hardwired version of where to pick up the tptp files for the moment *) |
|
15 |
(***************************************************************************) |
|
16 |
||
17 |
(*use "Proof_Transfer"; |
|
18 |
use "VampireCommunication"; |
|
16089
9169bdf930f8
trying to set up portable calling sequences for SPASS and tptp2X
paulson
parents:
16061
diff
changeset
|
19 |
use "SpassCommunication";*) |
15642 | 20 |
(*use "/homes/clq20/Jia_Code/TransStartIsar";*) |
21 |
||
22 |
||
23 |
structure Watcher: WATCHER = |
|
24 |
struct |
|
25 |
||
26 |
val goals_being_watched = ref 0; |
|
27 |
||
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
28 |
(*****************************************) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
29 |
(* The result of calling createWatcher *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
30 |
(*****************************************) |
15642 | 31 |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
32 |
datatype proc = PROC of { |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
33 |
pid : Posix.Process.pid, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
34 |
instr : TextIO.instream, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
35 |
outstr : TextIO.outstream |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
36 |
}; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
37 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
38 |
(*****************************************) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
39 |
(* The result of calling executeToList *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
40 |
(*****************************************) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
41 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
42 |
datatype cmdproc = CMDPROC of { |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
43 |
prover: string, (* Name of the resolution prover used, e.g. Vampire, SPASS *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
44 |
cmd: string, (* The file containing the goal for res prover to prove *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
45 |
thmstring: string, (* string representation of subgoal after negation, skolemization*) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
46 |
goalstring: string, (* string representation of subgoal*) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
47 |
proc_handle : (TextIO.instream,TextIO.outstream) Unix.proc, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
48 |
instr : TextIO.instream, (* Input stream to child process *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
49 |
outstr : TextIO.outstream (* Output stream from child process *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
50 |
}; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
51 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
52 |
type signal = Posix.Signal.signal |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
53 |
datatype exit_status = datatype Posix.Process.exit_status |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
54 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
55 |
val fromStatus = Posix.Process.fromStatus |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
56 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
57 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
58 |
fun reap(pid, instr, outstr) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
59 |
let |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
60 |
val u = TextIO.closeIn instr; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
61 |
val u = TextIO.closeOut outstr; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
62 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
63 |
val (_, status) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
64 |
Posix.Process.waitpid(Posix.Process.W_CHILD pid, []) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
65 |
in |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
66 |
status |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
67 |
end |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
68 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
69 |
fun fdReader (name : string, fd : Posix.IO.file_desc) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
70 |
Posix.IO.mkTextReader {initBlkMode = true,name = name,fd = fd }; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
71 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
72 |
fun fdWriter (name, fd) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
73 |
Posix.IO.mkTextWriter { |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
74 |
appendMode = false, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
75 |
initBlkMode = true, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
76 |
name = name, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
77 |
chunkSize=4096, |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
78 |
fd = fd |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
79 |
}; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
80 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
81 |
fun openOutFD (name, fd) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
82 |
TextIO.mkOutstream ( |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
83 |
TextIO.StreamIO.mkOutstream ( |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
84 |
fdWriter (name, fd), IO.BLOCK_BUF)); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
85 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
86 |
fun openInFD (name, fd) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
87 |
TextIO.mkInstream ( |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
88 |
TextIO.StreamIO.mkInstream ( |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
89 |
fdReader (name, fd), "")); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
90 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
91 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
92 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
93 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
94 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
95 |
fun killChild child_handle = Unix.reap child_handle |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
96 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
97 |
fun childInfo (PROC{pid,instr,outstr }) = (pid,(instr,outstr)); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
98 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
99 |
fun cmdstreamsOf (CMDPROC{instr,outstr,...}) = (instr, outstr); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
100 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
101 |
fun cmdInStream (CMDPROC{instr,outstr,...}) = (instr); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
102 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
103 |
fun cmdchildInfo (CMDPROC{prover,cmd,thmstring,proc_handle,goalstring,instr,outstr}) = (prover,(cmd, (instr,outstr))); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
104 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
105 |
fun cmdchildHandle (CMDPROC{prover,cmd,thmstring,goalstring,proc_handle,instr,outstr}) = proc_handle; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
106 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
107 |
fun cmdProver (CMDPROC{prover,cmd,thmstring,goalstring,proc_handle,instr,outstr}) = (prover); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
108 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
109 |
fun cmdThm (CMDPROC{prover,cmd,thmstring,goalstring,proc_handle,instr,outstr}) = (thmstring); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
110 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
111 |
fun cmdGoal (CMDPROC{prover,cmd,thmstring,goalstring,proc_handle,instr,outstr}) = (goalstring); |
15642 | 112 |
|
113 |
fun sendOutput (outstr,str) = (TextIO.outputSubstr (outstr, (Substring.all str));TextIO.flushOut outstr); |
|
114 |
||
115 |
(********************************************************************************************) |
|
116 |
(* takes a list of arguments and sends them individually to the watcher process by pipe *) |
|
117 |
(********************************************************************************************) |
|
118 |
||
119 |
fun outputArgs (toWatcherStr, []) = () |
|
120 |
| outputArgs (toWatcherStr, (x::xs)) = (TextIO.output (toWatcherStr, x); |
|
121 |
TextIO.flushOut toWatcherStr; |
|
122 |
outputArgs (toWatcherStr, xs)) |
|
123 |
||
124 |
(********************************************************************************) |
|
125 |
(* gets individual args from instream and concatenates them into a list *) |
|
126 |
(********************************************************************************) |
|
127 |
||
128 |
fun getArgs (fromParentStr, toParentStr,ys) = let |
|
129 |
val thisLine = TextIO.input fromParentStr |
|
130 |
in |
|
131 |
((ys@[thisLine])) |
|
132 |
end |
|
133 |
||
134 |
(********************************************************************************) |
|
135 |
(* Remove the \n character from the end of each filename *) |
|
136 |
(********************************************************************************) |
|
137 |
||
16478 | 138 |
(*fun getCmd cmdStr = let val backList = ((rev(explode cmdStr))) |
15642 | 139 |
in |
140 |
if (String.isPrefix "\n" (implode backList )) |
|
16089
9169bdf930f8
trying to set up portable calling sequences for SPASS and tptp2X
paulson
parents:
16061
diff
changeset
|
141 |
then (implode (rev ((tl backList)))) |
9169bdf930f8
trying to set up portable calling sequences for SPASS and tptp2X
paulson
parents:
16061
diff
changeset
|
142 |
else cmdStr |
16478 | 143 |
end*) |
15642 | 144 |
|
145 |
(********************************************************************************) |
|
146 |
(* Send request to Watcher for a vampire to be called for filename in arg *) |
|
147 |
(********************************************************************************) |
|
148 |
||
149 |
fun callResProver (toWatcherStr, arg) = (sendOutput (toWatcherStr, arg^"\n"); |
|
16089
9169bdf930f8
trying to set up portable calling sequences for SPASS and tptp2X
paulson
parents:
16061
diff
changeset
|
150 |
TextIO.flushOut toWatcherStr) |
15642 | 151 |
|
152 |
(*****************************************************************************************) |
|
16357 | 153 |
(* Send request to Watcher for multiple provers to be called for filenames in arg *) |
154 |
(* need to do the dfg stuff in the watcher, not here! send over the clasimp and stuff files too*) |
|
15642 | 155 |
(*****************************************************************************************) |
156 |
||
16357 | 157 |
|
15642 | 158 |
(* need to modify to send over hyps file too *) |
16475 | 159 |
fun callResProvers (toWatcherStr, []) = |
160 |
(sendOutput (toWatcherStr, "End of calls\n"); TextIO.flushOut toWatcherStr) |
|
161 |
| callResProvers (toWatcherStr, |
|
162 |
(prover,thmstring,goalstring, proverCmd,settings,clasimpfile, |
|
163 |
axfile, hypsfile,probfile) :: args) = |
|
164 |
let val _ = File.write (File.tmp_path (Path.basic "tog_comms")) |
|
165 |
(prover^thmstring^goalstring^proverCmd^settings^ |
|
166 |
clasimpfile^hypsfile^probfile) |
|
167 |
in sendOutput (toWatcherStr, |
|
168 |
(prover^"*"^thmstring^"*"^goalstring^"*"^proverCmd^"*"^ |
|
169 |
settings^"*"^clasimpfile^"*"^hypsfile^"*"^probfile^"\n")); |
|
170 |
goals_being_watched := (!goals_being_watched) + 1; |
|
171 |
TextIO.flushOut toWatcherStr; |
|
172 |
callResProvers (toWatcherStr,args) |
|
173 |
end |
|
16357 | 174 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16100
diff
changeset
|
175 |
|
15782 | 176 |
(* |
15642 | 177 |
fun callResProversStr (toWatcherStr, []) = "End of calls\n" |
178 |
||
15782 | 179 |
| callResProversStr (toWatcherStr,(prover,thmstring,goalstring, proverCmd,settings,clasimpfile, axfile, hypsfile, probfile)::args) = |
180 |
((prover^"*"^thmstring^"*"^goalstring^"*"^proverCmd^"*"^settings^"*"^clasimpfile^"*"^axfile^"*"^hypsfile^"*"^probfile^"\n") |
|
15642 | 181 |
|
15782 | 182 |
*) |
15642 | 183 |
|
184 |
(**************************************************************) |
|
185 |
(* Send message to watcher to kill currently running vampires *) |
|
186 |
(**************************************************************) |
|
187 |
||
188 |
fun callSlayer (toWatcherStr) = (sendOutput (toWatcherStr, "Kill vampires\n"); |
|
189 |
TextIO.flushOut toWatcherStr) |
|
190 |
||
191 |
||
192 |
||
193 |
(**************************************************************) |
|
194 |
(* Remove \n token from a vampire goal filename and extract *) |
|
195 |
(* prover, proverCmd, settings and file from input string *) |
|
196 |
(**************************************************************) |
|
197 |
||
198 |
||
199 |
fun takeUntil ch [] res = (res, []) |
|
200 |
| takeUntil ch (x::xs) res = if x = ch |
|
201 |
then |
|
202 |
(res, xs) |
|
203 |
else |
|
204 |
takeUntil ch xs (res@[x]) |
|
205 |
||
206 |
fun getSettings [] settings = settings |
|
207 |
| getSettings (xs) settings = let val (set, rest ) = takeUntil "%" xs [] |
|
208 |
in |
|
209 |
getSettings rest (settings@[(implode set)]) |
|
210 |
end |
|
211 |
||
16475 | 212 |
fun separateFields str = |
213 |
let val outfile = TextIO.openAppend(*("sep_field")*)(File.platform_path(File.tmp_path (Path.basic "sep_field"))) |
|
214 |
val _ = TextIO.output (outfile,("In separateFields, str is: "^(implode str)^"\n\n") ) |
|
215 |
val _ = TextIO.closeOut outfile |
|
216 |
val (prover, rest) = takeUntil "*" str [] |
|
217 |
val prover = implode prover |
|
16357 | 218 |
|
16475 | 219 |
val (thmstring, rest) = takeUntil "*" rest [] |
220 |
val thmstring = implode thmstring |
|
16357 | 221 |
|
16475 | 222 |
val (goalstring, rest) = takeUntil "*" rest [] |
223 |
val goalstring = implode goalstring |
|
16357 | 224 |
|
16475 | 225 |
val (proverCmd, rest ) = takeUntil "*" rest [] |
226 |
val proverCmd = implode proverCmd |
|
227 |
||
228 |
val (settings, rest) = takeUntil "*" rest [] |
|
229 |
val settings = getSettings settings [] |
|
16357 | 230 |
|
16475 | 231 |
val (clasimpfile, rest ) = takeUntil "*" rest [] |
232 |
val clasimpfile = implode clasimpfile |
|
233 |
||
234 |
val (hypsfile, rest ) = takeUntil "*" rest [] |
|
235 |
val hypsfile = implode hypsfile |
|
15642 | 236 |
|
16475 | 237 |
val (file, rest) = takeUntil "*" rest [] |
238 |
val file = implode file |
|
239 |
||
240 |
val _ = File.append (File.tmp_path (Path.basic "sep_comms")) |
|
241 |
("Sep comms are: "^(implode str)^"**"^ |
|
242 |
prover^thmstring^goalstring^proverCmd^clasimpfile^hypsfile^file^"\n\n") |
|
243 |
in |
|
244 |
(prover,thmstring,goalstring, proverCmd, settings, clasimpfile, hypsfile, file) |
|
245 |
end |
|
246 |
||
16357 | 247 |
|
248 |
(***********************************************************************************) |
|
249 |
(* do tptp2x and cat to turn clasimpfile, hypsfile and probfile into one .dfg file *) |
|
250 |
(***********************************************************************************) |
|
251 |
||
252 |
fun formatCmd (prover,thmstring,goalstring, proverCmd, settings, clasimpfile, hypsfile ,probfile) = |
|
16475 | 253 |
let |
254 |
(*** want to cat clasimp ax hyps prob, then send the resulting file to tptp2x ***) |
|
255 |
val probID = List.last(explode probfile) |
|
256 |
val wholefile = File.tmp_path (Path.basic ("ax_prob_" ^ probID)) |
|
257 |
||
258 |
(*** only include problem and clasimp for the moment, not sure |
|
259 |
how to refer to hyps/local axioms just now ***) |
|
260 |
val whole_prob_file = Unix.execute("/bin/cat", |
|
261 |
[clasimpfile,(*axfile, hypsfile,*)probfile, ">", |
|
262 |
File.platform_path wholefile]) |
|
263 |
||
264 |
val dfg_dir = File.tmp_path (Path.basic "dfg"); |
|
265 |
val dfg_path = File.platform_path dfg_dir; |
|
266 |
||
16515
7896ea4f3a87
VAMPIRE_HOME, helper_path and various stylistic tweaks
paulson
parents:
16478
diff
changeset
|
267 |
val tptp2X = ResLib.helper_path "TPTP2X_HOME" "tptp2X" |
16478 | 268 |
|
16561 | 269 |
(*** want to cat clasimp ax hyps prob, then send the resulting file to tptp2x ***) |
270 |
val probID = List.last(explode probfile) |
|
271 |
val wholefile = File.tmp_path (Path.basic ("ax_prob_"^probID)) |
|
16478 | 272 |
|
16561 | 273 |
(*** only include problem and clasimp for the moment, not sure how to refer to ***) |
274 |
(*** hyps/local axioms just now ***) |
|
275 |
val whole_prob_file = Unix.execute("/bin/cat", [clasimpfile,(*axfile, hypsfile,*)probfile, ">", (File.platform_path wholefile)]) |
|
276 |
(*** check if the directory exists and, if not, create it***) |
|
277 |
val _ = |
|
278 |
if !SpassComm.spass |
|
279 |
then |
|
280 |
if File.exists dfg_dir then warning("dfg dir exists") |
|
281 |
else File.mkdir dfg_dir |
|
282 |
else |
|
283 |
warning("not converting to dfg") |
|
284 |
||
285 |
val _ = if !SpassComm.spass then |
|
286 |
system (tptp2X ^ " -fdfg -d "^dfg_path^" "^ |
|
287 |
File.platform_path wholefile) |
|
288 |
else 7 |
|
289 |
val newfile = if !SpassComm.spass |
|
290 |
then |
|
291 |
dfg_path^"/ax_prob"^"_"^(probID)^".dfg" |
|
16478 | 292 |
else |
16561 | 293 |
(File.platform_path wholefile) |
294 |
val _ = File.append (File.tmp_path (Path.basic"thmstring_in_watcher")) |
|
295 |
(thmstring^"\n goals_watched"^(string_of_int(!goals_being_watched))^newfile^"\n") |
|
296 |
in |
|
297 |
(prover,thmstring,goalstring, proverCmd, settings,newfile) |
|
298 |
end; |
|
16478 | 299 |
|
16357 | 300 |
|
301 |
||
302 |
(* remove \n from end of command and put back into tuple format *) |
|
303 |
||
304 |
||
16478 | 305 |
(* val cmdStr = "spass*((ALL xa. (~ P x | P xa) & (~ P xa | P x)) & (P xa | (ALL x. P x)) & ((ALL x. ~ P x) | ~ P xb) [.])*(EX x. ALL y. P x = P y) --> (EX x. P x) = (ALL y. P y)*/homes/clq20/bin/SPASS*-DocProof*/local/scratch/clq20/27023/clasimp*/local/scratch/clq20/27023/hyps*/local/scratch/clq20/27023/prob_1\n" |
306 |
||
307 |
val cmdStr = "vampire*(length (rev xs) = length xs [.]) & (length (rev (a # xs)) ~= length (a # xs) [.])*length (rev []) = length []*/homes/jm318/Vampire8/vkernel*-t 300%-m 100000*/local/scratch/clq20/23523/clasimp*/local/scratch/clq20/23523/hyps*/local/scratch/clq20/23523/prob_1\n" |
|
308 |
*) |
|
16357 | 309 |
|
310 |
(*FIX: are the two getCmd procs getting confused? Why do I have two anyway? *) |
|
15642 | 311 |
|
16475 | 312 |
fun getCmd cmdStr = |
313 |
let val backList = rev(explode cmdStr) |
|
314 |
val _ = File.append (File.tmp_path (Path.basic"cmdStr")) cmdStr |
|
315 |
in |
|
316 |
if (String.isPrefix "\n" (implode backList )) |
|
317 |
then |
|
318 |
let val newCmdStr = (rev(tl backList)) |
|
319 |
in File.write (File.tmp_path (Path.basic"backlist")) |
|
320 |
("about to call sepfields with "^(implode newCmdStr)); |
|
321 |
formatCmd (separateFields newCmdStr) |
|
322 |
end |
|
323 |
else formatCmd (separateFields (explode cmdStr)) |
|
324 |
end |
|
15642 | 325 |
|
326 |
||
327 |
fun getProofCmd (a,b,c,d,e,f) = d |
|
328 |
||
16357 | 329 |
|
15642 | 330 |
(**************************************************************) |
331 |
(* Get commands from Isabelle *) |
|
332 |
(**************************************************************) |
|
16357 | 333 |
(* FIX: or perhaps do the tptp2x stuff here - so it's get commands and then format them, before passing them to spass *) |
15642 | 334 |
|
335 |
fun getCmds (toParentStr,fromParentStr, cmdList) = |
|
16475 | 336 |
let val thisLine = TextIO.inputLine fromParentStr |
337 |
val _ = File.append (File.tmp_path (Path.basic "parent_comms")) thisLine |
|
338 |
in |
|
339 |
if (thisLine = "End of calls\n") |
|
340 |
then cmdList |
|
341 |
else if (thisLine = "Kill children\n") |
|
342 |
then |
|
343 |
( TextIO.output (toParentStr,thisLine ); |
|
344 |
TextIO.flushOut toParentStr; |
|
345 |
(("","","","Kill children",[],"")::cmdList) |
|
346 |
) |
|
347 |
else let val thisCmd = getCmd (thisLine) |
|
348 |
(*********************************************************) |
|
349 |
(* thisCmd = (prover,thmstring,proverCmd, settings, file)*) |
|
350 |
(* i.e. put back into tuple format *) |
|
351 |
(*********************************************************) |
|
352 |
in |
|
353 |
(*TextIO.output (toParentStr, thisCmd); |
|
354 |
TextIO.flushOut toParentStr;*) |
|
355 |
getCmds (toParentStr,fromParentStr, (thisCmd::cmdList)) |
|
356 |
end |
|
357 |
end |
|
358 |
||
16357 | 359 |
|
15642 | 360 |
(**************************************************************) |
361 |
(* Get Io-descriptor for polling of an input stream *) |
|
362 |
(**************************************************************) |
|
363 |
||
364 |
||
365 |
fun getInIoDesc someInstr = |
|
366 |
let val (rd, buf) = TextIO.StreamIO.getReader(TextIO.getInstream someInstr) |
|
15702
2677db44c795
new signalling primmitives for sml/nj compatibility
paulson
parents:
15684
diff
changeset
|
367 |
val _ = TextIO.output (TextIO.stdOut, buf) |
15642 | 368 |
val ioDesc = |
369 |
case rd |
|
370 |
of TextPrimIO.RD{ioDesc = SOME iod, ...} =>SOME iod |
|
371 |
| _ => NONE |
|
372 |
in (* since getting the reader will have terminated the stream, we need |
|
373 |
* to build a new stream. *) |
|
374 |
TextIO.setInstream(someInstr, TextIO.StreamIO.mkInstream(rd, buf)); |
|
375 |
ioDesc |
|
376 |
end |
|
377 |
||
378 |
||
379 |
(*************************************) |
|
380 |
(* Set up a Watcher Process *) |
|
381 |
(*************************************) |
|
382 |
||
383 |
||
384 |
||
16061 | 385 |
fun setupWatcher (thm,clause_arr, num_of_clauses) = |
386 |
let |
|
387 |
(** pipes for communication between parent and watcher **) |
|
388 |
val p1 = Posix.IO.pipe () |
|
389 |
val p2 = Posix.IO.pipe () |
|
390 |
fun closep () = ( |
|
391 |
Posix.IO.close (#outfd p1); |
|
392 |
Posix.IO.close (#infd p1); |
|
393 |
Posix.IO.close (#outfd p2); |
|
394 |
Posix.IO.close (#infd p2) |
|
395 |
) |
|
396 |
(***********************************************************) |
|
397 |
(****** fork a watcher process and get it set up and going *) |
|
398 |
(***********************************************************) |
|
399 |
fun startWatcher (procList) = |
|
400 |
(case Posix.Process.fork() (***************************************) |
|
401 |
of SOME pid => pid (* parent - i.e. main Isabelle process *) |
|
402 |
(***************************************) |
|
403 |
||
404 |
(*************************) |
|
405 |
| NONE => let (* child - i.e. watcher *) |
|
406 |
val oldchildin = #infd p1 (*************************) |
|
407 |
val fromParent = Posix.FileSys.wordToFD 0w0 |
|
408 |
val oldchildout = #outfd p2 |
|
409 |
val toParent = Posix.FileSys.wordToFD 0w1 |
|
410 |
val fromParentIOD = Posix.FileSys.fdToIOD fromParent |
|
411 |
val fromParentStr = openInFD ("_exec_in_parent", fromParent) |
|
412 |
val toParentStr = openOutFD ("_exec_out_parent", toParent) |
|
413 |
val sign = sign_of_thm thm |
|
414 |
val prems = prems_of thm |
|
415 |
val prems_string = Meson.concat_with_and (map (Sign.string_of_term sign) prems) |
|
416 |
val _ = (warning ("subgoals forked to startWatcher: "^prems_string)); |
|
417 |
(* tracing *) |
|
418 |
(*val tenth_ax = fst( Array.sub(clause_arr, 1)) |
|
419 |
val tenth_ax_thms = memo_find_clause (tenth_ax, clause_tab) |
|
420 |
val clause_str = Meson.concat_with_and (map string_of_thm tenth_ax_thms) |
|
421 |
val _ = (warning ("tenth axiom in array in watcher is: "^tenth_ax)) |
|
422 |
val _ = (warning ("tenth axiom in table in watcher is: "^clause_str)) |
|
423 |
val _ = (warning ("num_of_clauses in watcher is: "^(string_of_int (num_of_clauses))) ) |
|
424 |
*) |
|
425 |
(*val goalstr = string_of_thm (the_goal) |
|
16260 | 426 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "goal_in_watcher"))); |
16061 | 427 |
val _ = TextIO.output (outfile,goalstr ) |
428 |
val _ = TextIO.closeOut outfile*) |
|
429 |
fun killChildren [] = () |
|
430 |
| killChildren (child_handle::children) = (killChild child_handle; killChildren children) |
|
15642 | 431 |
|
16061 | 432 |
|
433 |
||
434 |
(*************************************************************) |
|
435 |
(* take an instream and poll its underlying reader for input *) |
|
436 |
(*************************************************************) |
|
15642 | 437 |
|
16061 | 438 |
fun pollParentInput () = |
16475 | 439 |
let val pd = OS.IO.pollDesc (fromParentIOD) |
440 |
in |
|
441 |
if (isSome pd ) then |
|
442 |
let val pd' = OS.IO.pollIn (valOf pd) |
|
443 |
val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) |
|
444 |
val _ = File.append (File.tmp_path (Path.basic "parent_poll")) |
|
445 |
("In parent_poll\n") |
|
446 |
in |
|
447 |
if null pdl |
|
448 |
then |
|
449 |
NONE |
|
450 |
else if (OS.IO.isIn (hd pdl)) |
|
451 |
then |
|
452 |
(SOME ( getCmds (toParentStr, fromParentStr, []))) |
|
453 |
else |
|
16061 | 454 |
NONE |
16475 | 455 |
end |
456 |
else |
|
457 |
NONE |
|
458 |
end |
|
16061 | 459 |
|
460 |
fun pollChildInput (fromStr) = |
|
16478 | 461 |
|
462 |
let val _ = File.append (File.tmp_path (Path.basic "child_poll")) |
|
463 |
("In child_poll\n") |
|
464 |
val iod = getInIoDesc fromStr |
|
465 |
in |
|
466 |
||
467 |
||
468 |
||
16061 | 469 |
if isSome iod |
470 |
then |
|
471 |
let val pd = OS.IO.pollDesc (valOf iod) |
|
472 |
in |
|
473 |
if (isSome pd ) then |
|
474 |
let val pd' = OS.IO.pollIn (valOf pd) |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16100
diff
changeset
|
475 |
val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) |
16478 | 476 |
|
16061 | 477 |
in |
478 |
if null pdl |
|
479 |
then |
|
16478 | 480 |
( File.append (File.tmp_path (Path.basic "child_poll_res")) |
481 |
("Null pdl \n");NONE) |
|
16061 | 482 |
else if (OS.IO.isIn (hd pdl)) |
483 |
then |
|
16478 | 484 |
(let val inval = (TextIO.inputLine fromStr) |
485 |
val _ = File.append (File.tmp_path (Path.basic "child_poll_res")) (inval^"\n") |
|
486 |
in |
|
487 |
SOME inval |
|
488 |
end) |
|
16061 | 489 |
else |
16478 | 490 |
( File.append (File.tmp_path (Path.basic "child_poll_res")) |
491 |
("Null pdl \n");NONE) |
|
16061 | 492 |
end |
493 |
else |
|
494 |
NONE |
|
495 |
end |
|
496 |
else |
|
497 |
NONE |
|
16475 | 498 |
end |
15642 | 499 |
|
500 |
||
16061 | 501 |
(****************************************************************************) |
502 |
(* Check all vampire processes currently running for output *) |
|
503 |
(****************************************************************************) |
|
504 |
(*********************************) |
|
505 |
fun checkChildren ([], toParentStr) = [] (*** no children to check ********) |
|
506 |
(*********************************) |
|
507 |
| checkChildren ((childProc::otherChildren), toParentStr) = |
|
16357 | 508 |
let val _ = File.append (File.tmp_path (Path.basic "child_check")) |
509 |
("In check child, length of queue:"^(string_of_int (length (childProc::otherChildren)))^"\n") |
|
510 |
val (childInput,childOutput) = cmdstreamsOf childProc |
|
16061 | 511 |
val child_handle= cmdchildHandle childProc |
512 |
(* childCmd is the .dfg file that the problem is in *) |
|
513 |
val childCmd = fst(snd (cmdchildInfo childProc)) |
|
16357 | 514 |
val _ = File.append (File.tmp_path (Path.basic "child_command")) |
515 |
(childCmd^"\n") |
|
16061 | 516 |
(* now get the number of the subgoal from the filename *) |
16520 | 517 |
val sg_num = if (!SpassComm.spass ) |
518 |
then |
|
519 |
int_of_string(ReconOrderClauses.get_nth 5 (rev(explode childCmd))) |
|
520 |
else |
|
521 |
int_of_string(hd (rev(explode childCmd))) |
|
522 |
||
16061 | 523 |
val childIncoming = pollChildInput childInput |
16357 | 524 |
val _ = File.append (File.tmp_path (Path.basic "child_check_polled")) |
525 |
("finished polling child \n") |
|
16061 | 526 |
val parentID = Posix.ProcEnv.getppid() |
527 |
val prover = cmdProver childProc |
|
528 |
val thmstring = cmdThm childProc |
|
529 |
val sign = sign_of_thm thm |
|
530 |
val prems = prems_of thm |
|
531 |
val prems_string = Meson.concat_with_and (map (Sign.string_of_term sign) prems) |
|
16100 | 532 |
val _ = warning("subgoals forked to checkChildren: "^prems_string) |
533 |
val goalstring = cmdGoal childProc |
|
16357 | 534 |
val _ = File.append (File.tmp_path (Path.basic "child_comms")) |
535 |
(prover^thmstring^goalstring^childCmd^"\n") |
|
16061 | 536 |
in |
537 |
if (isSome childIncoming) |
|
538 |
then |
|
539 |
(* check here for prover label on child*) |
|
16100 | 540 |
let val _ = File.write (File.tmp_path (Path.basic "child_incoming")) ("subgoals forked to checkChildren: "^prems_string^prover^thmstring^goalstring^childCmd) |
16478 | 541 |
val childDone = (case prover of |
542 |
"vampire" => (VampComm.checkVampProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses) ) |
|
543 |
|"spass" => (SpassComm.checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses) ) ) |
|
16061 | 544 |
in |
545 |
if childDone (**********************************************) |
|
546 |
then (* child has found a proof and transferred it *) |
|
547 |
(**********************************************) |
|
15642 | 548 |
|
16061 | 549 |
(**********************************************) |
550 |
(* Remove this child and go on to check others*) |
|
551 |
(**********************************************) |
|
552 |
( Unix.reap child_handle; |
|
553 |
checkChildren(otherChildren, toParentStr)) |
|
554 |
else |
|
555 |
(**********************************************) |
|
556 |
(* Keep this child and go on to check others *) |
|
557 |
(**********************************************) |
|
15642 | 558 |
|
16061 | 559 |
(childProc::(checkChildren (otherChildren, toParentStr))) |
560 |
end |
|
561 |
else |
|
16100 | 562 |
(File.append (File.tmp_path (Path.basic "child_incoming")) "No child output "; |
563 |
childProc::(checkChildren (otherChildren, toParentStr))) |
|
16061 | 564 |
end |
15642 | 565 |
|
16061 | 566 |
|
567 |
(********************************************************************) |
|
568 |
(* call resolution processes *) |
|
569 |
(* settings should be a list of strings *) |
|
16520 | 570 |
(* e.g. ["-t 300", "-m 100000"] (TextIO.input instr)^ *) |
16061 | 571 |
(* takes list of (string, string, string list, string)list proclist *) |
572 |
(********************************************************************) |
|
15642 | 573 |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
574 |
|
16061 | 575 |
(*** add subgoal id num to this *) |
576 |
fun execCmds [] procList = procList |
|
16561 | 577 |
| execCmds ((prover, thmstring,goalstring,proverCmd,settings,file)::cmds) procList = let val _ = File.append (File.tmp_path (Path.basic "pre_exec_child")) ("\nAbout to execute command for goal:\n"^goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now())))) |
16357 | 578 |
in |
579 |
if (prover = "spass") |
|
16561 | 580 |
then |
581 |
let val childhandle:(TextIO.instream,TextIO.outstream) Unix.proc = |
|
582 |
(Unix.execute(proverCmd, (["-FullRed=0"]@settings@[file]))) |
|
583 |
val (instr, outstr) = Unix.streamsOf childhandle |
|
584 |
val newProcList = (((CMDPROC{ |
|
585 |
prover = prover, |
|
586 |
cmd = file, |
|
587 |
thmstring = thmstring, |
|
588 |
goalstring = goalstring, |
|
589 |
proc_handle = childhandle, |
|
590 |
instr = instr, |
|
591 |
outstr = outstr })::procList)) |
|
592 |
val _ = File.append (File.tmp_path (Path.basic "exec_child")) |
|
593 |
("\nexecuting command for goal:\n"^ |
|
594 |
goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now())))) |
|
595 |
in |
|
596 |
Posix.Process.sleep (Time.fromSeconds 1);execCmds cmds newProcList |
|
597 |
end |
|
598 |
else |
|
599 |
let val childhandle:(TextIO.instream,TextIO.outstream) Unix.proc = |
|
600 |
(Unix.execute(proverCmd, (settings@[file]))) |
|
601 |
val (instr, outstr) = Unix.streamsOf childhandle |
|
602 |
||
603 |
val newProcList = (((CMDPROC{ |
|
604 |
prover = prover, |
|
605 |
cmd = file, |
|
606 |
thmstring = thmstring, |
|
607 |
goalstring = goalstring, |
|
608 |
proc_handle = childhandle, |
|
609 |
instr = instr, |
|
610 |
outstr = outstr })::procList)) |
|
611 |
||
612 |
val _ = File.append (File.tmp_path (Path.basic "exec_child")) ("executing command for goal:\n"^goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now())))) |
|
613 |
in |
|
614 |
Posix.Process.sleep (Time.fromSeconds 1); execCmds cmds newProcList |
|
615 |
end |
|
16357 | 616 |
end |
15642 | 617 |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
618 |
|
16061 | 619 |
(****************************************) |
620 |
(* call resolution processes remotely *) |
|
621 |
(* settings should be a list of strings *) |
|
622 |
(* e.g. ["-t 300", "-m 100000"] *) |
|
623 |
(****************************************) |
|
624 |
||
625 |
(* fun execRemoteCmds [] procList = procList |
|
626 |
| execRemoteCmds ((prover, thmstring,goalstring,proverCmd ,settings,file)::cmds) procList = |
|
627 |
let val newProcList = mySshExecuteToList ("/usr/bin/ssh",([prover,thmstring,goalstring,"-t", "shep"]@[proverCmd]@settings@[file]), procList) |
|
628 |
in |
|
629 |
execRemoteCmds cmds newProcList |
|
630 |
end |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
631 |
*) |
15642 | 632 |
|
16061 | 633 |
fun printList (outStr, []) = () |
634 |
| printList (outStr, (x::xs)) = (TextIO.output (outStr, x);TextIO.flushOut outStr; printList (outStr,xs)) |
|
15642 | 635 |
|
636 |
||
16061 | 637 |
(**********************************************) |
638 |
(* Watcher Loop *) |
|
639 |
(**********************************************) |
|
640 |
||
15642 | 641 |
|
642 |
||
643 |
||
16061 | 644 |
fun keepWatching (toParentStr, fromParentStr,procList) = |
645 |
let fun loop (procList) = |
|
646 |
( |
|
647 |
let val cmdsFromIsa = pollParentInput () |
|
648 |
fun killchildHandler (n:int) = (TextIO.output(toParentStr, "Killing child proof processes!\n"); |
|
649 |
TextIO.flushOut toParentStr; |
|
650 |
killChildren (map (cmdchildHandle) procList); |
|
651 |
()) |
|
652 |
||
653 |
in |
|
654 |
(*Signal.signal (Posix.Signal.usr2, Signal.SIG_HANDLE killchildHandler);*) |
|
655 |
(**********************************) |
|
656 |
if (isSome cmdsFromIsa) then (* deal with input from Isabelle *) |
|
657 |
( (**********************************) |
|
658 |
if (getProofCmd(hd(valOf cmdsFromIsa)) = "Kill children" ) |
|
659 |
then |
|
660 |
( |
|
661 |
let val child_handles = map cmdchildHandle procList |
|
662 |
in |
|
663 |
killChildren child_handles; |
|
664 |
(*Posix.Process.kill(Posix.Process.K_PROC (Posix.ProcEnv.getppid()), Posix.Signal.usr2);*) loop ([]) |
|
665 |
end |
|
666 |
||
667 |
) |
|
668 |
else |
|
669 |
( |
|
670 |
if ((length procList)<10) (********************) |
|
671 |
then (* Execute locally *) |
|
672 |
( (********************) |
|
673 |
let |
|
674 |
val newProcList = execCmds (valOf cmdsFromIsa) procList |
|
675 |
val parentID = Posix.ProcEnv.getppid() |
|
16357 | 676 |
val _ = (File.append (File.tmp_path (Path.basic "prekeep_watch")) "Just execed a child\n ") |
16061 | 677 |
val newProcList' =checkChildren (newProcList, toParentStr) |
16357 | 678 |
|
679 |
val _ = warning("off to keep watching...") |
|
680 |
val _ = (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching...\n ") |
|
16061 | 681 |
in |
682 |
(*Posix.Process.sleep (Time.fromSeconds 1);*) |
|
683 |
loop (newProcList') |
|
684 |
end |
|
685 |
) |
|
686 |
else (*********************************) |
|
687 |
(* Execute remotely *) |
|
688 |
(* (actually not remote for now )*) |
|
689 |
( (*********************************) |
|
690 |
let |
|
691 |
val newProcList = execCmds (valOf cmdsFromIsa) procList |
|
692 |
val parentID = Posix.ProcEnv.getppid() |
|
693 |
val newProcList' =checkChildren (newProcList, toParentStr) |
|
694 |
in |
|
695 |
(*Posix.Process.sleep (Time.fromSeconds 1);*) |
|
696 |
loop (newProcList') |
|
697 |
end |
|
698 |
) |
|
15642 | 699 |
|
700 |
||
701 |
||
16061 | 702 |
) |
703 |
) (******************************) |
|
704 |
else (* No new input from Isabelle *) |
|
705 |
(******************************) |
|
706 |
( let val newProcList = checkChildren ((procList), toParentStr) |
|
707 |
in |
|
16357 | 708 |
(*Posix.Process.sleep (Time.fromSeconds 1);*) |
709 |
(File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching.2..\n "); |
|
16061 | 710 |
loop (newProcList) |
711 |
end |
|
712 |
||
713 |
) |
|
714 |
end) |
|
715 |
in |
|
716 |
loop (procList) |
|
717 |
end |
|
718 |
||
719 |
||
720 |
in |
|
721 |
(***************************) |
|
722 |
(*** Sort out pipes ********) |
|
723 |
(***************************) |
|
15642 | 724 |
|
16061 | 725 |
Posix.IO.close (#outfd p1); |
726 |
Posix.IO.close (#infd p2); |
|
727 |
Posix.IO.dup2{old = oldchildin, new = fromParent}; |
|
728 |
Posix.IO.close oldchildin; |
|
729 |
Posix.IO.dup2{old = oldchildout, new = toParent}; |
|
730 |
Posix.IO.close oldchildout; |
|
15642 | 731 |
|
16061 | 732 |
(***************************) |
733 |
(* start the watcher loop *) |
|
734 |
(***************************) |
|
735 |
keepWatching (toParentStr, fromParentStr, procList); |
|
15642 | 736 |
|
737 |
||
16061 | 738 |
(****************************************************************************) |
739 |
(* fake return value - actually want the watcher to loop until killed *) |
|
740 |
(****************************************************************************) |
|
741 |
Posix.Process.wordToPid 0w0 |
|
742 |
||
743 |
end); |
|
744 |
(* end case *) |
|
15642 | 745 |
|
746 |
||
16061 | 747 |
val _ = TextIO.flushOut TextIO.stdOut |
15642 | 748 |
|
16061 | 749 |
(*******************************) |
750 |
(*** set watcher going ********) |
|
751 |
(*******************************) |
|
15642 | 752 |
|
16061 | 753 |
val procList = [] |
754 |
val pid = startWatcher (procList) |
|
755 |
(**************************************************) |
|
756 |
(* communication streams to watcher *) |
|
757 |
(**************************************************) |
|
15642 | 758 |
|
16061 | 759 |
val instr = openInFD ("_exec_in", #infd p2) |
760 |
val outstr = openOutFD ("_exec_out", #outfd p1) |
|
761 |
||
762 |
in |
|
763 |
(*******************************) |
|
764 |
(* close the child-side fds *) |
|
765 |
(*******************************) |
|
766 |
Posix.IO.close (#outfd p2); |
|
767 |
Posix.IO.close (#infd p1); |
|
768 |
(* set the fds close on exec *) |
|
769 |
Posix.IO.setfd (#infd p2, Posix.IO.FD.flags [Posix.IO.FD.cloexec]); |
|
770 |
Posix.IO.setfd (#outfd p1, Posix.IO.FD.flags [Posix.IO.FD.cloexec]); |
|
771 |
||
772 |
(*******************************) |
|
773 |
(* return value *) |
|
774 |
(*******************************) |
|
775 |
PROC{pid = pid, |
|
776 |
instr = instr, |
|
777 |
outstr = outstr |
|
778 |
} |
|
779 |
end; |
|
15642 | 780 |
|
781 |
||
782 |
||
783 |
(**********************************************************) |
|
784 |
(* Start a watcher and set up signal handlers *) |
|
785 |
(**********************************************************) |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
786 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
787 |
fun killWatcher pid= Posix.Process.kill(Posix.Process.K_PROC pid, Posix.Signal.kill); |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
788 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
789 |
fun reapWatcher(pid, instr, outstr) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
790 |
let |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
791 |
val u = TextIO.closeIn instr; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
792 |
val u = TextIO.closeOut outstr; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
793 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
794 |
val (_, status) = |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
795 |
Posix.Process.waitpid(Posix.Process.W_CHILD pid, []) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
796 |
in |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
797 |
status |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15919
diff
changeset
|
798 |
end |
15642 | 799 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16100
diff
changeset
|
800 |
|
16520 | 801 |
|
802 |
fun createWatcher (thm,clause_arr, ( num_of_clauses:int)) = let val mychild = childInfo (setupWatcher(thm,clause_arr, num_of_clauses)) |
|
803 |
val streams =snd mychild |
|
804 |
val childin = fst streams |
|
805 |
val childout = snd streams |
|
806 |
val childpid = fst mychild |
|
807 |
val sign = sign_of_thm thm |
|
808 |
val prems = prems_of thm |
|
809 |
val prems_string = Meson.concat_with_and (map (Sign.string_of_term sign) prems) |
|
810 |
val _ = (warning ("subgoals forked to createWatcher: "^prems_string)); |
|
811 |
fun vampire_proofHandler (n) = |
|
812 |
(Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
|
813 |
VampComm.getVampInput childin; Pretty.writeln(Pretty.str (oct_char "361"));() ) |
|
814 |
||
815 |
||
816 |
fun spass_proofHandler (n) = ( |
|
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
817 |
let val outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "foo_signal1"))); |
16520 | 818 |
val _ = TextIO.output (outfile, ("In signal handler now\n")) |
819 |
val _ = TextIO.closeOut outfile |
|
820 |
val (reconstr, goalstring, thmstring) = SpassComm.getSpassInput childin |
|
821 |
val outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "foo_signal"))); |
|
822 |
||
823 |
val _ = TextIO.output (outfile, ("In signal handler "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched)))) |
|
824 |
val _ = TextIO.closeOut outfile |
|
825 |
in (* if a proof has been found and sent back as a reconstruction proof *) |
|
826 |
if ( (substring (reconstr, 0,1))= "[") |
|
827 |
then |
|
15642 | 828 |
|
16520 | 829 |
( |
830 |
Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
|
831 |
Recon_Transfer.apply_res_thm reconstr goalstring; |
|
832 |
Pretty.writeln(Pretty.str (oct_char "361")); |
|
833 |
||
834 |
goals_being_watched := ((!goals_being_watched) - 1); |
|
835 |
||
836 |
if ((!goals_being_watched) = 0) |
|
837 |
then |
|
838 |
(let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_found"))); |
|
839 |
val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
|
840 |
val _ = TextIO.closeOut outfile |
|
841 |
in |
|
842 |
killWatcher (childpid); reapWatcher (childpid,childin, childout); () |
|
843 |
end) |
|
844 |
else |
|
845 |
() |
|
846 |
) |
|
847 |
(* if there's no proof, but a message from Spass *) |
|
848 |
else if ((substring (reconstr, 0,5))= "SPASS") |
|
849 |
then |
|
850 |
( |
|
851 |
goals_being_watched := (!goals_being_watched) -1; |
|
852 |
Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
|
853 |
Pretty.writeln(Pretty.str ((Recon_Transfer.restore_linebreaks goalstring)^reconstr)); |
|
854 |
Pretty.writeln(Pretty.str (oct_char "361")); |
|
855 |
if (!goals_being_watched = 0) |
|
856 |
then |
|
857 |
(let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_comp"))); |
|
858 |
val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
|
859 |
val _ = TextIO.closeOut outfile |
|
860 |
in |
|
861 |
killWatcher (childpid); reapWatcher (childpid,childin, childout); () |
|
862 |
end ) |
|
863 |
else |
|
864 |
() |
|
865 |
) |
|
866 |
(* print out a list of rules used from clasimpset*) |
|
867 |
else if ((substring (reconstr, 0,5))= "Rules") |
|
868 |
then |
|
869 |
( |
|
870 |
goals_being_watched := (!goals_being_watched) -1; |
|
871 |
Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
|
872 |
Pretty.writeln(Pretty.str (goalstring^reconstr)); |
|
873 |
Pretty.writeln(Pretty.str (oct_char "361")); |
|
874 |
if (!goals_being_watched = 0) |
|
875 |
then |
|
876 |
(let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_comp"))); |
|
877 |
val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
|
878 |
val _ = TextIO.closeOut outfile |
|
879 |
in |
|
880 |
killWatcher (childpid); reapWatcher (childpid,childin, childout);() |
|
881 |
end ) |
|
882 |
else |
|
883 |
() |
|
884 |
) |
|
885 |
||
886 |
(* if proof translation failed *) |
|
887 |
else if ((substring (reconstr, 0,5)) = "Proof") |
|
888 |
then |
|
889 |
( |
|
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
890 |
goals_being_watched := (!goals_being_watched) -1; |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
891 |
Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
892 |
Pretty.writeln(Pretty.str (goalstring^(Recon_Transfer.restore_linebreaks reconstr))); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
893 |
Pretty.writeln(Pretty.str (oct_char "361")); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
894 |
if (!goals_being_watched = 0) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
895 |
then |
16520 | 896 |
(let val outfile = TextIO.openOut(File.platform_path (File.tmp_path (Path.basic "foo_reap_comp"))); |
897 |
val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
|
898 |
val _ = TextIO.closeOut outfile |
|
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
899 |
in |
16520 | 900 |
killWatcher (childpid); reapWatcher (childpid,childin, childout); () |
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
901 |
end ) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
902 |
else |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
903 |
( ) |
16520 | 904 |
) |
905 |
||
906 |
||
907 |
else (* add something here ?*) |
|
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
908 |
( |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
909 |
goals_being_watched := (!goals_being_watched) -1; |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
910 |
Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
911 |
Pretty.writeln(Pretty.str ("Ran out of options in handler")); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
912 |
Pretty.writeln(Pretty.str (oct_char "361")); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
913 |
if (!goals_being_watched = 0) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
914 |
then |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
915 |
(let val outfile = TextIO.openOut(File.platform_path (File.tmp_path (Path.basic "foo_reap_comp"))); |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
916 |
val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
917 |
val _ = TextIO.closeOut outfile |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
918 |
in |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
919 |
killWatcher (childpid); reapWatcher (childpid,childin, childout); () |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
920 |
end ) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
921 |
else |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
922 |
( ) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
923 |
) |
16520 | 924 |
|
925 |
||
926 |
||
927 |
end) |
|
928 |
||
929 |
||
930 |
||
931 |
in IsaSignal.signal (IsaSignal.usr1, IsaSignal.SIG_HANDLE vampire_proofHandler); |
|
932 |
IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE spass_proofHandler); |
|
933 |
(childin, childout, childpid) |
|
934 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16100
diff
changeset
|
935 |
|
15642 | 936 |
|
16100 | 937 |
end |
15642 | 938 |
|
939 |
||
940 |
||
941 |
||
942 |
||
943 |
end (* structure Watcher *) |