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