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