src/HOL/Tools/ATP/watcher.ML
author quigley
Wed, 20 Apr 2005 18:01:50 +0200
changeset 15782 a1863ea9052b
parent 15774 9df37a0e935d
child 15787 8fad4bd4e53c
permissions -rw-r--r--
Corrected the problem with the ATP directory.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     2
 (*  Title:      Watcher.ML
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     3
     Author:     Claire Quigley
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     4
     Copyright   2004  University of Cambridge
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";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    18
use "SpassCommunication";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    19
use "modUnix";*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    20
(*use "/homes/clq20/Jia_Code/TransStartIsar";*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    21
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    22
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    23
structure Watcher: WATCHER =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    24
  struct
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    25
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    26
val goals_being_watched = ref 0;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    27
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    28
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    29
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    30
fun sendOutput (outstr,str) = (TextIO.outputSubstr (outstr, (Substring.all str));TextIO.flushOut outstr);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    31
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    32
(********************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    33
(*  takes a list of arguments and sends them individually to the watcher process by pipe    *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    34
(********************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    35
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    36
fun outputArgs (toWatcherStr, []) = ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    37
|   outputArgs (toWatcherStr, (x::xs)) = (TextIO.output (toWatcherStr, x); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    38
                                          TextIO.flushOut toWatcherStr;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    39
                                         outputArgs (toWatcherStr, xs))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    40
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    41
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    42
(*    gets individual args from instream and concatenates them into a list      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    43
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    44
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    45
fun getArgs (fromParentStr, toParentStr,ys) =  let 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    46
                                       val thisLine = TextIO.input fromParentStr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    47
                                    in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    48
                                        ((ys@[thisLine]))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    49
                                    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    50
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    51
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
(*  Remove the \n character from the end of each filename                       *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    54
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    55
fun getCmd cmdStr = let val backList = ((rev(explode cmdStr))) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    56
                    in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    57
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    58
                        if (String.isPrefix "\n"  (implode backList )) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    59
                        then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    60
                             (implode (rev ((tl backList))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    61
                        else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    62
                           (cmdStr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
                    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    64
                            
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    65
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    66
(*  Send request to Watcher for a vampire to be called for filename in arg      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    67
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    68
                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    69
fun callResProver (toWatcherStr,  arg) = (sendOutput (toWatcherStr, arg^"\n"); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    70
                                     TextIO.flushOut toWatcherStr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    71
                                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    72
                                     )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    73
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    74
(*****************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    75
(*  Send request to Watcher for multiple provers to be called for filenames in arg      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    76
(*****************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    77
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    78
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    79
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    80
(* need to modify to send over hyps file too *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    81
fun callResProvers (toWatcherStr,  []) = (sendOutput (toWatcherStr, "End of calls\n"); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    82
                                     TextIO.flushOut toWatcherStr)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    83
|   callResProvers (toWatcherStr,(prover,thmstring,goalstring, proverCmd,settings,clasimpfile, axfile, hypsfile,probfile)::args) =
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    84
                                                     let val dfg_dir = File.tmp_path (Path.basic "dfg"); 
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    85
                                                        (*** need to check here if the directory exists and, if not, create it***)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    86
                                                         val  outfile = TextIO.openAppend(File.sysify_path
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    87
                                                                               (File.tmp_path (Path.basic"thmstring_in_watcher")));                                                                         val _ = TextIO.output (outfile, 
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    88
                                                                       (thmstring^"\n goals_watched"^(string_of_int(!goals_being_watched))^"\n"))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    89
                                                         val _ =  TextIO.closeOut outfile
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    90
                                                        (*** want to cat clasimp ax hyps prob, then send the resulting file to tptp2x ***)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    91
							val probID = last(explode probfile)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    92
                                                         val wholefile = File.tmp_path (Path.basic ("ax_prob_"^probID))
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    93
                                                         (*** only include problem and clasimp for the moment, not sure how to refer to ***)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    94
                                                         (*** hyps/local axioms just now                                                ***)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    95
                                                         val whole_prob_file = Unix.execute("/bin/cat", [(*clasimpfile, axfile, hypsfile,*)probfile,  ">", (File.sysify_path wholefile)])
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    96
                                                         val dfg_create =if File.exists dfg_dir 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    97
                                                                         then
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
    98
                                                                             ((warning("dfg dir exists"));())
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    99
                                                                         else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   100
                                                                               File.mkdir dfg_dir; 
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   101
                                                         
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   102
                                                         val dfg_path = File.sysify_path dfg_dir;
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   103
                                                         val exec_tptp2x = Unix.execute("/usr/groups/theory/tptp/TPTP-v3.0.1/TPTP2X/tptp2X",
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   104
                                                                                       ["-fdfg ",(File.sysify_path wholefile)," -d ",dfg_path])
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   105
                                                       (*val _ = Posix.Process.wait ()*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   106
                                                       (*val _ =Unix.reap exec_tptp2x*)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   107
                                                         val newfile = dfg_path^"/ax_prob"^"_"^(probID)^".dfg"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   108
                                       
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   109
                                                      in   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   110
                                                         goals_being_watched := (!goals_being_watched) + 1;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   111
                                                         OS.Process.sleep(Time.fromSeconds 1); 
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   112
                     					(warning ("probfile is: "^probfile));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   113
                                                         (warning("dfg file is: "^newfile));
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   114
                                                         (warning ("wholefile is: "^(File.sysify_path wholefile)));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   115
                                                         sendOutput (toWatcherStr, (prover^"*"^thmstring^"*"^goalstring^"*"^proverCmd^"*"^settings^"*"^newfile^"\n"));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   116
                                                         TextIO.flushOut toWatcherStr;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   117
                                                         Unix.reap exec_tptp2x; 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   118
                                                         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   119
                                                         callResProvers (toWatcherStr,args)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   120
                                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   121
                                                     end
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   122
(*
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   123
fun callResProversStr (toWatcherStr,  []) =  "End of calls\n" 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   124
                                     
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   125
|   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
   126
                                            ((prover^"*"^thmstring^"*"^goalstring^"*"^proverCmd^"*"^settings^"*"^clasimpfile^"*"^axfile^"*"^hypsfile^"*"^probfile^"\n")
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   127
                                            
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   128
     *)                                      
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   129
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   130
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   131
(* Send message to watcher to kill currently running vampires *)
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
fun callSlayer (toWatcherStr) = (sendOutput (toWatcherStr, "Kill vampires\n"); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   135
                            TextIO.flushOut toWatcherStr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   136
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   137
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   138
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   139
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   140
(* Remove \n token from a vampire goal filename and extract   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   141
(* prover, proverCmd, settings and file from input string     *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   142
(**************************************************************)
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
 fun takeUntil ch [] res  = (res, [])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   146
 |   takeUntil ch (x::xs) res = if   x = ch 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   147
                                then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   148
                                     (res, xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   149
                                else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   150
                                     takeUntil ch xs (res@[x])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   151
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   152
 fun getSettings [] settings = settings
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   153
|    getSettings (xs) settings = let val (set, rest ) = takeUntil "%" xs []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   154
                                 in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   155
                                     getSettings rest (settings@[(implode set)])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   156
                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   157
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   158
fun separateFields str = let val (prover, rest) = takeUntil "*" str []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   159
                              val prover = implode prover
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   160
                              val (thmstring, rest) =  takeUntil "*" rest []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   161
                              val thmstring = implode thmstring
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   162
                              val (goalstring, rest) =  takeUntil "*" rest []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   163
                              val goalstring = implode goalstring
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   164
                              val (proverCmd, rest ) =  takeUntil "*" rest []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   165
                              val proverCmd = implode proverCmd
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   166
                              
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   167
                              val (settings, rest) =  takeUntil "*" rest []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   168
                              val settings = getSettings settings []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   169
                              val (file, rest) =  takeUntil "*" rest []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   170
                              val file = implode file
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   171
                              val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "sep_comms")));                                                                                    
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   172
                              val _ = TextIO.output (outfile,(prover^thmstring^goalstring^proverCmd^file) )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   173
                              val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   174
                              
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   175
                          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   176
                             (prover,thmstring,goalstring, proverCmd, settings, file)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   177
                          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   178
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   179
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   180
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   181
 fun getCmd cmdStr = let val backList = ((rev(explode cmdStr))) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   182
                     in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   183
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   184
                         if (String.isPrefix "\n"  (implode backList )) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   185
                         then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   186
                             separateFields ((rev ((tl backList))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   187
                         else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   188
                           (separateFields (explode cmdStr))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   189
                     end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   190
                      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   191
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   192
fun getProofCmd (a,b,c,d,e,f) = d
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   193
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   194
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   195
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   196
(* Get commands from Isabelle                                 *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   197
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   198
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   199
fun getCmds (toParentStr,fromParentStr, cmdList) = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   200
                                       let val thisLine = TextIO.inputLine fromParentStr 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   201
                                       in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   202
                                          (if (thisLine = "End of calls\n") 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   203
                                           then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   204
                                              (cmdList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   205
                                           else if (thisLine = "Kill children\n") 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   206
                                                then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   207
                                                    (   TextIO.output (toParentStr,thisLine ); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   208
                                                        TextIO.flushOut toParentStr;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   209
                                                      (("","","","Kill children",[],"")::cmdList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   210
                                                     )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   211
                                              else (let val thisCmd = getCmd (thisLine) (* thisCmd = (prover,thmstring,proverCmd, settings, file)*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   212
                                                    in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   213
                                                      (*TextIO.output (toParentStr, thisCmd); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   214
                                                        TextIO.flushOut toParentStr;*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   215
                                                        getCmds (toParentStr,fromParentStr, (thisCmd::cmdList))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   216
                                                    end
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
                                        end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   220
                                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   221
                                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   222
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   223
(*  Get Io-descriptor for polling of an input stream          *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   224
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   225
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   226
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   227
fun getInIoDesc someInstr = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   228
    let val (rd, buf) = TextIO.StreamIO.getReader(TextIO.getInstream someInstr)
15702
2677db44c795 new signalling primmitives for sml/nj compatibility
paulson
parents: 15684
diff changeset
   229
        val _ = TextIO.output (TextIO.stdOut, buf)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   230
        val ioDesc = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   231
	    case rd
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   232
	      of TextPrimIO.RD{ioDesc = SOME iod, ...} =>SOME iod
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   233
	       | _ => NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   234
     in (* since getting the reader will have terminated the stream, we need
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   235
	 * to build a new stream. *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   236
	TextIO.setInstream(someInstr, TextIO.StreamIO.mkInstream(rd, buf));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   237
	ioDesc
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   238
    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   239
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   240
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   241
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   242
(*  Set up a Watcher Process         *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   243
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   244
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   245
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   246
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   247
fun setupWatcher (thm) = let
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   248
          (** pipes for communication between parent and watcher **)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   249
          val p1 = Posix.IO.pipe ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   250
          val p2 = Posix.IO.pipe ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   251
	  fun closep () = (
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   252
                Posix.IO.close (#outfd p1); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   253
                Posix.IO.close (#infd p1);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   254
                Posix.IO.close (#outfd p2); 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   255
                Posix.IO.close (#infd p2)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   256
              )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   257
          (***********************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   258
          (****** fork a watcher process and get it set up and going *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   259
          (***********************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   260
          fun startWatcher (procList) =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   261
                   (case  Posix.Process.fork() (***************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   262
		 of SOME pid =>  pid           (* parent - i.e. main Isabelle process *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   263
                                               (***************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   264
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   265
                                                 (*************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   266
                  | NONE => let                  (* child - i.e. watcher  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   267
		      val oldchildin = #infd p1  (*************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   268
		      val fromParent = Posix.FileSys.wordToFD 0w0
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   269
		      val oldchildout = #outfd p2
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   270
		      val toParent = Posix.FileSys.wordToFD 0w1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   271
                      val fromParentIOD = Posix.FileSys.fdToIOD fromParent
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   272
                      val fromParentStr = openInFD ("_exec_in_parent", fromParent)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   273
                      val toParentStr = openOutFD ("_exec_out_parent", toParent)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   274
                      val sign = sign_of_thm thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   275
                      val prems = prems_of thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   276
                      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
   277
                      val _ = (warning ("subgoals forked to startWatcher: "^prems_string));
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   278
                      (*val goalstr = string_of_thm (the_goal)
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   279
                       val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "goal_in_watcher")));  
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   280
                      val _ = TextIO.output (outfile,goalstr )
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   281
                      val _ =  TextIO.closeOut outfile*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   282
                      fun killChildren [] = ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   283
                   |      killChildren  (childPid::children) = (killChild childPid; killChildren children)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   284
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   285
                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   286
           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   287
                    (*************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   288
                    (* take an instream and poll its underlying reader for input *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   289
                    (*************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   290
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   291
                    fun pollParentInput () = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   292
                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   293
                               let val pd = OS.IO.pollDesc (fromParentIOD)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   294
                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   295
                               if (isSome pd ) then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   296
                                   let val pd' = OS.IO.pollIn (valOf pd)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   297
                                       val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 100)) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   298
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   299
                                      if null pdl 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   300
                                      then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   301
                                         NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   302
                                      else if (OS.IO.isIn (hd pdl)) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   303
                                           then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   304
                                              (SOME ( getCmds (toParentStr, fromParentStr, [])))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   305
                                           else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   306
                                               NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   307
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   308
                                 else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   309
                                     NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   310
                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   311
                            
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   312
                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   313
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   314
                     fun pollChildInput (fromStr) = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   315
                           let val iod = getInIoDesc fromStr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   316
                           in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   317
                           if isSome iod 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   318
                           then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   319
                               let val pd = OS.IO.pollDesc (valOf iod)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   320
                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   321
                               if (isSome pd ) then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   322
                                   let val pd' = OS.IO.pollIn (valOf pd)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   323
                                       val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 100)) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   324
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   325
                                      if null pdl 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   326
                                      then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   327
                                         NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   328
                                      else if (OS.IO.isIn (hd pdl)) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   329
                                           then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   330
                                               SOME (getCmd (TextIO.inputLine fromStr))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   331
                                           else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   332
                                               NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   333
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   334
                                 else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   335
                                     NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   336
                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   337
                             else 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   338
                                 NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   339
                            end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   340
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   341
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   342
                   (****************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   343
                   (* Check all vampire processes currently running for output                 *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   344
                   (****************************************************************************) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   345
                                                              (*********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   346
                    fun checkChildren ([], toParentStr) = []  (*** no children to check ********)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   347
                                                              (*********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   348
                    |   checkChildren ((childProc::otherChildren), toParentStr) = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   349
                                            let val (childInput,childOutput) =  cmdstreamsOf childProc
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   350
                                                val childPid = cmdchildPid childProc
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   351
                                                (* childCmd is the .dfg file that the problem is in *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   352
                                                val childCmd = fst(snd (cmdchildInfo childProc))
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   353
                                                (* now get the number of the subgoal from the filename *)
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   354
                                                val sg_num = int_of_string(get_nth 5 (rev(explode childCmd)))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   355
                                                val childIncoming = pollChildInput childInput
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   356
                                                val parentID = Posix.ProcEnv.getppid()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   357
                                                val prover = cmdProver childProc
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   358
                                                val thmstring = cmdThm childProc
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   359
                                                val sign = sign_of_thm thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   360
                                                val prems = prems_of thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   361
                                                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
   362
                                                val _ = (warning ("subgoals forked to checkChildren: "^prems_string));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   363
                                                val goalstring = cmdGoal childProc
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   364
                                                                                                       
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   365
                                                val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "child_comms")));  
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   366
                                                val _ = TextIO.output (outfile,(prover^thmstring^goalstring^childCmd) )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   367
                                                val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   368
                                            in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   369
                                              if (isSome childIncoming) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   370
                                              then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   371
                                                  (* check here for prover label on child*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   372
                                                   
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   373
                                                  let val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "child_incoming")));  
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   374
                                                val _ = TextIO.output (outfile,(("subgoals forked to checkChildren: "^prems_string)^prover^thmstring^goalstring^childCmd) )
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   375
                                                val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   376
                                              val childDone = (case prover of
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   377
                                    (* "vampire" => startVampireTransfer(childInput, toParentStr, parentID, childCmd)                                               |*)"spass" => (checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num)     ) )
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   378
                                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   379
                                                    if childDone      (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   380
                                                    then              (* child has found a proof and transferred it *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   381
                                                                      (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   382
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   383
                                                       (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   384
                                                       (* Remove this child and go on to check others*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   385
                                                       (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   386
                                                       ( reap(childPid, childInput, childOutput);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   387
                                                         checkChildren(otherChildren, toParentStr))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   388
                                                    else 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   389
                                                       (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   390
                                                       (* Keep this child and go on to check others  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   391
                                                       (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   392
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   393
                                                         (childProc::(checkChildren (otherChildren, toParentStr)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   394
                                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   395
                                               else
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   396
                                                   let val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "child_incoming")));  
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   397
                                                val _ = TextIO.output (outfile,"No child output " )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   398
                                                val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   399
                                                 in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   400
                                                    (childProc::(checkChildren (otherChildren, toParentStr)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   401
                                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   402
                                            end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   403
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   404
                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   405
                (********************************************************************)                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   406
                (* call resolution processes                                        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   407
                (* settings should be a list of strings                             *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   408
                (* e.g. ["-t 300", "-m 100000"]                                     *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   409
                (* takes list of (string, string, string list, string)list proclist *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   410
                (********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   411
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   412
           (*** add subgoal id num to this *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   413
                   fun execCmds  [] procList = procList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   414
                   |   execCmds  ((prover, thmstring,goalstring,proverCmd,settings,file)::cmds) procList  = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   415
                                                     if (prover = "spass") 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   416
                                                     then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   417
                                                         let val newProcList = myexecuteToList (proverCmd,([prover]@[thmstring]@[goalstring]@["-FullRed=0"]@settings@[file]), procList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   418
                                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   419
                                                            execCmds cmds newProcList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   420
                                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   421
                                                     else 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   422
                                                         let val newProcList = myexecuteToList (proverCmd,([prover]@[thmstring]@[goalstring]@settings@[file]), procList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   423
                                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   424
                                                            execCmds cmds newProcList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   425
                                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   426
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   427
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   428
                (****************************************)                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   429
                (* call resolution processes remotely   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   430
                (* settings should be a list of strings *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   431
                (* e.g. ["-t 300", "-m 100000"]         *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   432
                (****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   433
  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   434
                   fun execRemoteCmds  [] procList = procList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   435
                   |   execRemoteCmds ((prover, thmstring,goalstring,proverCmd ,settings,file)::cmds) procList  =  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   436
                                             let val  newProcList =  mySshExecuteToList ("/usr/bin/ssh",([prover,thmstring,goalstring,"-t", "shep"]@[proverCmd]@settings@[file]), procList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   437
                                                 in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   438
                                                      execRemoteCmds  cmds newProcList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   439
                                                 end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   440
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   441
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   442
                   fun printList (outStr, []) = ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   443
                   |   printList (outStr, (x::xs)) = (TextIO.output (outStr, x);TextIO.flushOut outStr; printList (outStr,xs))                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   444
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   445
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   446
                (**********************************************)                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   447
                (* Watcher Loop                               *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   448
                (**********************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   449
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   450
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   451
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   452
   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   453
                    fun keepWatching (toParentStr, fromParentStr,procList) = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   454
                          let    fun loop (procList) =  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   455
                                 (
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   456
                                 let val cmdsFromIsa = pollParentInput ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   457
                                      fun killchildHandler (n:int)  = (TextIO.output(toParentStr, "Killing child proof processes!\n");
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   458
                                                  TextIO.flushOut toParentStr;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   459
                                                   killChildren (map (cmdchildPid) procList);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   460
                                                    ())
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   461
                                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   462
                                 in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   463
                                    (*Signal.signal (Posix.Signal.usr2, Signal.SIG_HANDLE killchildHandler);*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   464
                                                                                       (**********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   465
                                    if (isSome cmdsFromIsa) then                       (*  deal with input from Isabelle *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   466
                                         (                                             (**********************************)                             
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   467
                                          if (getProofCmd(hd(valOf cmdsFromIsa)) = "Kill children" )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   468
                                          then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   469
                                            (
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   470
                                              let val childPids = map cmdchildPid procList 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   471
                                              in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   472
                                                 killChildren childPids;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   473
                                                 (*Posix.Process.kill(Posix.Process.K_PROC (Posix.ProcEnv.getppid()), Posix.Signal.usr2);*)                                       loop ([])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   474
                                              end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   475
                                             )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   476
                                          else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   477
                                            ( 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   478
                                              if ((length procList)<2)    (********************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   479
                                              then                        (* Execute locally  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   480
                                                 (                        (********************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   481
                                                  let 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   482
                                                    val newProcList = execCmds (valOf cmdsFromIsa) procList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   483
                                                    val parentID = Posix.ProcEnv.getppid()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   484
                                                    val newProcList' =checkChildren (newProcList, toParentStr) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   485
                                                  in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   486
                                                    (*OS.Process.sleep (Time.fromSeconds 1);*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   487
                                                    loop (newProcList') 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   488
                                                  end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   489
                                                  )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   490
                                              else                         (************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   491
                                                                           (* Execute remotely     *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   492
                                                  (                        (************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   493
                                                  let 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   494
                                                    val newProcList = execRemoteCmds (valOf cmdsFromIsa) procList
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   495
                                                    val parentID = Posix.ProcEnv.getppid()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   496
                                                    val newProcList' =checkChildren (newProcList, toParentStr) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   497
                                                  in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   498
                                                    (*OS.Process.sleep (Time.fromSeconds 1);*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   499
                                                    loop (newProcList') 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   500
                                                  end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   501
                                                  )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   502
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   503
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   504
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   505
                                              )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   506
                                           )                                              (******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   507
                                    else                                                  (* No new input from Isabelle *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   508
                                                                                          (******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   509
                                        (    let val newProcList = checkChildren ((procList), toParentStr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   510
                                             in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   511
                                               OS.Process.sleep (Time.fromSeconds 1);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   512
                                               loop (newProcList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   513
                                             end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   514
                                         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   515
                                         )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   516
                                  end)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   517
                          in  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   518
                              loop (procList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   519
                          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   520
                      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   521
          
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   522
                      in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   523
                       (***************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   524
                       (*** Sort out pipes ********)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   525
                       (***************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   526
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   527
			Posix.IO.close (#outfd p1);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   528
			Posix.IO.close (#infd p2);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   529
			Posix.IO.dup2{old = oldchildin, new = fromParent};
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   530
                        Posix.IO.close oldchildin;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   531
			Posix.IO.dup2{old = oldchildout, new = toParent};
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   532
                        Posix.IO.close oldchildout;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   533
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   534
                        (***************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   535
                        (* start the watcher loop  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   536
                        (***************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   537
                        keepWatching (toParentStr, fromParentStr, procList);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   538
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   539
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   540
                        (****************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   541
                        (* fake return value - actually want the watcher to loop until killed       *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   542
                        (****************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   543
                        Posix.Process.wordToPid 0w0
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   544
			
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   545
		      end);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   546
		(* end case *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   547
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   548
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   549
          val _ = TextIO.flushOut TextIO.stdOut
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   550
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   551
          (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   552
          (***  set watcher going ********)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   553
          (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   554
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   555
          val procList = []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   556
          val pid = startWatcher (procList)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   557
          (**************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   558
          (* communication streams to watcher               *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   559
          (**************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   560
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   561
	  val instr = openInFD ("_exec_in", #infd p2)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   562
          val outstr = openOutFD ("_exec_out", #outfd p1)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   563
          
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   564
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   565
           (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   566
           (* close the child-side fds    *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   567
           (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   568
            Posix.IO.close (#outfd p2);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   569
            Posix.IO.close (#infd p1);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   570
            (* set the fds close on exec *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   571
            Posix.IO.setfd (#infd p2, Posix.IO.FD.flags [Posix.IO.FD.cloexec]);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   572
            Posix.IO.setfd (#outfd p1, Posix.IO.FD.flags [Posix.IO.FD.cloexec]);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   573
             
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   574
           (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   575
           (* return value                *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   576
           (*******************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   577
            PROC{pid = pid,
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   578
              instr = instr,
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   579
              outstr = outstr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   580
            }
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   581
         end;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   582
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   583
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   584
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   585
(**********************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   586
(* Start a watcher and set up signal handlers             *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   587
(**********************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   588
fun killWatcher pid= killChild pid;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   589
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   590
fun createWatcher (thm) = let val mychild = childInfo (setupWatcher(thm))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   591
			   val streams =snd mychild
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   592
                           val childin = fst streams
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   593
                           val childout = snd streams
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   594
                           val childpid = fst mychild
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   595
                           val sign = sign_of_thm thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   596
                           val prems = prems_of thm
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   597
                           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
   598
                           val _ = (warning ("subgoals forked to createWatcher: "^prems_string));
15702
2677db44c795 new signalling primmitives for sml/nj compatibility
paulson
parents: 15684
diff changeset
   599
                           fun vampire_proofHandler (n) =
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   600
                           (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
   601
                           getVampInput childin; Pretty.writeln(Pretty.str  (oct_char "361"));() )               
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   602
                          
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   603
15702
2677db44c795 new signalling primmitives for sml/nj compatibility
paulson
parents: 15684
diff changeset
   604
fun spass_proofHandler (n) = (
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   605
                                 let  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal1")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   606
                                      val _ = TextIO.output (outfile, ("In signal handler now\n"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   607
                                      val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   608
                                      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
   609
                                      val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "foo_signal")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   610
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   611
                                      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
   612
                                      val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   613
                                      in          (* if a proof has been found and sent back as a reconstruction proof *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   614
                                                  if ( (substring (reconstr, 0,1))= "[")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   615
                                                  then 
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
                                                                 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
   619
                                                                 Recon_Transfer.apply_res_thm reconstr goalstring;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   620
                                                                 Pretty.writeln(Pretty.str  (oct_char "361"));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   621
                                                                 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   622
                                                                 goals_being_watched := ((!goals_being_watched) - 1);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   623
                                                         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   624
                                                                 if ((!goals_being_watched) = 0)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   625
                                                                 then 
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   626
                                                                    (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
   627
                                                                         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
   628
                                                                         val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   629
                                                                     in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   630
                                                                         reap (childpid,childin, childout); ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   631
                                                                     end)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   632
                                                                 else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   633
                                                                    ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   634
                                                            )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   635
                                                    (* if there's no proof, but a message from Spass *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   636
                                                    else if ((substring (reconstr, 0,5))= "SPASS")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   637
                                                         then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   638
                                                                 (
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   639
                                                                     goals_being_watched := (!goals_being_watched) -1;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   640
                                                                     Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   641
                                                                      Pretty.writeln(Pretty.str (goalstring^reconstr));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   642
                                                                      Pretty.writeln(Pretty.str  (oct_char "361"));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   643
                                                                      if (!goals_being_watched = 0)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   644
                                                                      then 
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   645
                                                                          (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
   646
                                                                               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
   647
                                                                               val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   648
                                                                           in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   649
                                                                              reap (childpid,childin, childout); ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   650
                                                                           end )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   651
                                                                      else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   652
                                                                         ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   653
                                                                )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   654
                                                          (* if proof translation failed *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   655
                                                          else if ((substring (reconstr, 0,5)) = "Proof")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   656
                                                               then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   657
                                                                   (
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   658
                                                                     goals_being_watched := (!goals_being_watched) -1;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   659
                                                                     Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   660
                                                                      Pretty.writeln(Pretty.str (goalstring^reconstr));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   661
                                                                      Pretty.writeln(Pretty.str  (oct_char "361"));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   662
                                                                      if (!goals_being_watched = 0)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   663
                                                                      then 
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15652
diff changeset
   664
                                                                          (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
   665
                                                                               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
   666
                                                                               val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   667
                                                                           in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   668
                                                                              reap (childpid,childin, childout); ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   669
                                                                           end )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   670
                                                                      else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   671
                                                                         ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   672
                                                                )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   673
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   674
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   675
                                                                else  (* add something here ?*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   676
                                                                   ()
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   677
                                                             
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   678
                                       end)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   679
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   680
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   681
                        
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   682
                       in IsaSignal.signal (IsaSignal.usr1, IsaSignal.SIG_HANDLE vampire_proofHandler);
15702
2677db44c795 new signalling primmitives for sml/nj compatibility
paulson
parents: 15684
diff changeset
   683
                          IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE spass_proofHandler);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   684
                          (childin, childout, childpid)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   685
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   686
                       end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   687
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   688
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   689
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   690
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   691
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   692
end (* structure Watcher *)