src/HOL/Tools/ATP/watcher.ML
author paulson
Tue, 20 Sep 2005 13:17:55 +0200
changeset 17502 8836793df947
parent 17488 67376a311a2b
child 17525 ae5bb6001afb
permissions -rw-r--r--
further tidying; killing of old Watcher loops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15789
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     1
(*  Title:      Watcher.ML
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     2
    ID:         $Id$
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     3
    Author:     Claire Quigley
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     4
    Copyright   2004  University of Cambridge
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     5
 *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     6
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     7
 (***************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     8
 (*  The watcher process starts a resolution process when it receives a     *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     9
(*  message from Isabelle                                                  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    10
(*  Signals Isabelle, puts output of child into pipe to Isabelle,          *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    11
(*  and removes dead processes.  Also possible to kill all the resolution  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    12
(*  processes currently running.                                           *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    13
(*  Hardwired version of where to pick up the tptp files for the moment    *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    14
(***************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    15
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    16
signature WATCHER =
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    17
sig
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    18
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    19
(*****************************************************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    20
(*  Send request to Watcher for multiple spasses to be called for filenames in arg       *)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    21
(*  callResProvers (outstreamtoWatcher, prover name,prover-command, (settings,file) list             *)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    22
(*****************************************************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    23
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    24
val callResProvers :
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
    25
    TextIO.outstream * (string*string*string*string*string) list 
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    26
    -> unit
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    27
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    28
(************************************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    29
(* Send message to watcher to kill currently running resolution provers *)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    30
(************************************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    31
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    32
val callSlayer : TextIO.outstream -> unit
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    33
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    34
(**********************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    35
(* Start a watcher and set up signal handlers             *)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    36
(**********************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    37
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    38
val createWatcher : 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    39
    thm * (ResClause.clause * thm) Array.array -> 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    40
    TextIO.instream * TextIO.outstream * Posix.Process.pid
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    41
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    42
(**********************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    43
(* Kill watcher process                                   *)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    44
(**********************************************************)
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    45
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    46
val killWatcher : Posix.Process.pid -> unit
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
    47
val killWatcher' : int -> unit
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    48
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    49
end
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    50
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
    51
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
structure Watcher: WATCHER =
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
    54
struct
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    55
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
    56
open Recon_Transfer
16805
fadf80952202 open ReconPrelim Recon_Transfer;
wenzelm
parents: 16767
diff changeset
    57
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    58
val goals_being_watched = ref 0;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    59
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    60
(*****************************************)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    61
(*  The result of calling createWatcher  *)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    62
(*****************************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    64
datatype proc = PROC of {
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    65
        pid : Posix.Process.pid,
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    66
        instr : TextIO.instream,
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    67
        outstr : TextIO.outstream
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    68
      };
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    69
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    70
(*****************************************)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    71
(*  The result of calling executeToList  *)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    72
(*****************************************)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    73
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    74
datatype cmdproc = CMDPROC of {
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    75
        prover: string,             (* Name of the resolution prover used, e.g. Vampire, SPASS *)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    76
        cmd:  string,              (* The file containing the goal for res prover to prove *)     
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    77
        goalstring: string,         (* string representation of subgoal*) 
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    78
        proc_handle : (TextIO.instream,TextIO.outstream) Unix.proc,
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    79
        instr : TextIO.instream,   (*  Input stream to child process *)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    80
        outstr : TextIO.outstream  (*  Output stream from child process *)
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    81
      };
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    82
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    83
type signal = Posix.Signal.signal
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    84
datatype exit_status = datatype Posix.Process.exit_status
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    85
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    86
val fromStatus = Posix.Process.fromStatus
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    87
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    88
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    89
fun reap(pid, instr, outstr) =
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    90
  let val u = TextIO.closeIn instr;
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    91
      val u = TextIO.closeOut outstr;
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    92
      val (_, status) = Posix.Process.waitpid(Posix.Process.W_CHILD pid, [])
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    93
  in
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    94
	  status
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
    95
  end
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    96
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    97
fun fdReader (name : string, fd : Posix.IO.file_desc) =
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    98
	  Posix.IO.mkTextReader {initBlkMode = true,name = name,fd = fd };
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
    99
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   100
fun fdWriter (name, fd) =
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   101
          Posix.IO.mkTextWriter {
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   102
	      appendMode = false,
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   103
              initBlkMode = true,
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   104
              name = name,  
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   105
              chunkSize=4096,
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   106
              fd = fd};
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   107
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   108
fun openOutFD (name, fd) =
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   109
	  TextIO.mkOutstream (
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   110
	    TextIO.StreamIO.mkOutstream (
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   111
	      fdWriter (name, fd), IO.BLOCK_BUF));
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   112
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   113
fun openInFD (name, fd) =
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   114
	  TextIO.mkInstream (
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   115
	    TextIO.StreamIO.mkInstream (
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   116
	      fdReader (name, fd), ""));
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   117
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   118
fun childInfo (PROC{pid,instr,outstr }) = (pid,(instr,outstr));
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   119
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   120
fun cmdstreamsOf (CMDPROC{instr,outstr,...}) = (instr, outstr);
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   121
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   122
fun cmdInStream (CMDPROC{instr,outstr,...}) = instr;
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   123
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   124
fun cmdchildInfo (CMDPROC{prover,cmd,proc_handle,goalstring,instr,outstr}) = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   125
  (prover,(cmd, (instr,outstr)));
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   126
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   127
fun cmdchildHandle (CMDPROC{prover,cmd,goalstring,proc_handle,instr,outstr})  = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   128
  proc_handle;
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   129
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   130
fun cmdProver (CMDPROC{prover,cmd,goalstring,proc_handle,instr,outstr})  =
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   131
  prover;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   132
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   133
fun cmdGoal (CMDPROC{prover,cmd,goalstring,proc_handle,instr,outstr})  =
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   134
  goalstring;
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   135
15642
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
(*    gets individual args from instream and concatenates them into a list      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   139
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   140
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   141
fun getArgs (fromParentStr, toParentStr, ys) =  
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   142
  let val thisLine = TextIO.input fromParentStr
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   143
  in ys@[thisLine] end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   144
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   145
                            
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   146
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   147
(*  Send request to Watcher for a vampire to be called for filename in arg      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   148
(********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   149
                    
17231
f42bc4f7afdf tidying up the Isabelle/ATP interface
paulson
parents: 17216
diff changeset
   150
fun callResProver (toWatcherStr,  arg) = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   151
      (TextIO.output (toWatcherStr, arg^"\n"); 
17231
f42bc4f7afdf tidying up the Isabelle/ATP interface
paulson
parents: 17216
diff changeset
   152
       TextIO.flushOut toWatcherStr)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   153
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   154
(*****************************************************************************************)
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16260
diff changeset
   155
(*  Send request to Watcher for multiple provers to be called for filenames in arg       *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16260
diff changeset
   156
(*  need to do the dfg stuff in the watcher, not here! send over the clasimp and stuff files too*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   157
(*****************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   158
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16260
diff changeset
   159
    
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   160
(*Uses the $-character to separate items sent to watcher*)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   161
fun callResProvers (toWatcherStr,  []) = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   162
      (TextIO.output (toWatcherStr, "End of calls\n");  TextIO.flushOut toWatcherStr)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   163
|   callResProvers (toWatcherStr,
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   164
                    (prover,goalstring, proverCmd,settings, 
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   165
                     probfile)  ::  args) =
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   166
      let val _ = File.write (File.tmp_path (Path.basic "tog_comms"))
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   167
                             (prover^goalstring^proverCmd^settings^
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   168
                              probfile)
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   169
      in TextIO.output (toWatcherStr,    
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   170
            (prover^"$"^goalstring^"$"^proverCmd^"$"^
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   171
             settings^"$"^probfile^"\n"));
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   172
         goals_being_watched := (!goals_being_watched) + 1;
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   173
	 TextIO.flushOut toWatcherStr;
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   174
	 callResProvers (toWatcherStr,args)
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   175
      end   
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16260
diff changeset
   176
                                                
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   177
                                    
15642
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
(* Send message to watcher to kill currently running vampires *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   181
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   182
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   183
fun callSlayer toWatcherStr = (TextIO.output (toWatcherStr, "Kill vampires\n"); 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   184
                            TextIO.flushOut toWatcherStr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   185
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   186
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   187
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   188
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   189
(* Remove \n token from a vampire goal filename and extract   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   190
(* prover, proverCmd, settings and file from input string     *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   191
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   192
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   193
fun separateFields str =
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   194
  let val _ = File.append (File.tmp_path (Path.basic "sep_field"))
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   195
                          ("In separateFields, str is: " ^ str ^ "\n\n") 
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   196
      val [prover,goalstring,proverCmd,settingstr,probfile] = 
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   197
          String.tokens (fn c => c = #"$") str
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   198
      val settings = String.tokens (fn c => c = #"%") settingstr
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   199
      val _ = File.append (File.tmp_path (Path.basic "sep_comms"))                                                                                
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   200
                  ("Sep comms are: "^ str ^"**"^
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   201
                   prover^" goalstr:  "^goalstring^
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   202
                   "\n provercmd: "^proverCmd^
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   203
                   "\n prob  "^probfile^"\n\n")
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   204
  in
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   205
     (prover,goalstring, proverCmd, settings, probfile)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   206
  end
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   207
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   208
val remove_newlines = String.translate (fn c => if c = #"\n" then "" else str c);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   209
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   210
fun getCmd cmdStr = 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   211
  let val cmdStr' = remove_newlines cmdStr
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   212
  in
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   213
      File.write (File.tmp_path (Path.basic"sepfields_call")) 
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   214
		 ("about to call separateFields with " ^ cmdStr');
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   215
      separateFields cmdStr'
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   216
  end;
15642
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
(* Get commands from Isabelle                                 *)
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
fun getCmds (toParentStr,fromParentStr, cmdList) = 
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   223
  let val thisLine = TextIO.inputLine fromParentStr 
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   224
      val _ = File.append (File.tmp_path (Path.basic "parent_comms")) thisLine
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   225
  in
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   226
     if thisLine = "End of calls\n" then cmdList
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   227
     else if thisLine = "Kill children\n"
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   228
     then 
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   229
	 (   TextIO.output (toParentStr,thisLine ); 
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   230
	     TextIO.flushOut toParentStr;
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   231
	   (("","","Kill children",[],"")::cmdList)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   232
	  )
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   233
     else let val thisCmd = getCmd thisLine 
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   234
	       (*********************************************************)
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   235
	       (* thisCmd = (prover,proverCmd, settings, file)*)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   236
	       (* i.e. put back into tuple format                       *)
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   237
	       (*********************************************************)
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   238
	   in
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   239
	     (*TextIO.output (toParentStr, thisCmd); 
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   240
	       TextIO.flushOut toParentStr;*)
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   241
	       getCmds (toParentStr, fromParentStr, thisCmd::cmdList)
16475
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   242
	   end
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   243
  end
8f3ba52a7937 using TPTP2X_HOME; indentation, etc
paulson
parents: 16357
diff changeset
   244
	    
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16260
diff changeset
   245
                                                                  
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   246
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   247
(*  Get Io-descriptor for polling of an input stream          *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   248
(**************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   249
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   250
fun getInIoDesc someInstr = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   251
    let val (rd, buf) = TextIO.StreamIO.getReader(TextIO.getInstream someInstr)
15702
2677db44c795 new signalling primmitives for sml/nj compatibility
paulson
parents: 15684
diff changeset
   252
        val _ = TextIO.output (TextIO.stdOut, buf)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   253
        val ioDesc = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   254
	    case rd
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   255
	      of TextPrimIO.RD{ioDesc = SOME iod, ...} =>SOME iod
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   256
	       | _ => NONE
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   257
     in (* since getting the reader will have terminated the stream, we need
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   258
	 * to build a new stream. *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   259
	TextIO.setInstream(someInstr, TextIO.StreamIO.mkInstream(rd, buf));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   260
	ioDesc
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   261
    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   262
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
(*  Set up a Watcher Process         *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   266
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   267
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   268
fun getProofCmd (a,c,d,e,f) = d
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   269
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   270
fun prems_string_of th =
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   271
  Meson.concat_with_and (map (Sign.string_of_term (sign_of_thm th)) (prems_of th))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   272
17502
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   273
fun killChildren procs = List.app (ignore o Unix.reap) procs;
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   274
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   275
fun setupWatcher (thm,clause_arr) = 
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   276
  let
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   277
    (** pipes for communication between parent and watcher **)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   278
    val p1 = Posix.IO.pipe ()
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   279
    val p2 = Posix.IO.pipe ()
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   280
    fun closep () = 
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   281
	 (Posix.IO.close (#outfd p1); 
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   282
	  Posix.IO.close (#infd p1);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   283
	  Posix.IO.close (#outfd p2); 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   284
	  Posix.IO.close (#infd p2))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   285
    (***********************************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   286
    (****** fork a watcher process and get it set up and going *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   287
    (***********************************************************)
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   288
    fun startWatcher procList =
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   289
     (case  Posix.Process.fork() (***************************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   290
      of SOME pid =>  pid           (* parent - i.e. main Isabelle process *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   291
				    (***************************************)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   292
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   293
				      (*************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   294
       | NONE => let                  (* child - i.e. watcher  *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   295
	   val oldchildin = #infd p1  (*************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   296
	   val fromParent = Posix.FileSys.wordToFD 0w0
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   297
	   val oldchildout = #outfd p2
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   298
	   val toParent = Posix.FileSys.wordToFD 0w1
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   299
	   val fromParentIOD = Posix.FileSys.fdToIOD fromParent
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   300
	   val fromParentStr = openInFD ("_exec_in_parent", fromParent)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   301
	   val toParentStr = openOutFD ("_exec_out_parent", toParent)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   302
	   val _ = debug ("subgoals forked to startWatcher: "^ prems_string_of thm);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   303
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   304
	 (*************************************************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   305
	 (* take an instream and poll its underlying reader for input *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   306
	 (*************************************************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   307
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   308
	 fun pollParentInput () = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   309
	   let val pd = OS.IO.pollDesc fromParentIOD
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   310
	   in 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   311
	     if isSome pd then 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   312
		 let val pd' = OS.IO.pollIn (valOf pd)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   313
		     val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   314
		     val _ = File.append (File.tmp_path (Path.basic "parent_poll")) 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   315
		       ("In parent_poll\n")	
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   316
		 in
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   317
		    if null pdl 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   318
		    then
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   319
		       NONE
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   320
		    else if (OS.IO.isIn (hd pdl)) 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   321
			 then SOME (getCmds (toParentStr, fromParentStr, []))
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   322
			 else NONE
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   323
		 end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   324
	       else NONE
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   325
	   end
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   326
		 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   327
	  fun pollChildInput fromStr = 
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   328
	   let val _ = File.append (File.tmp_path (Path.basic "child_poll")) 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   329
			 ("In child_poll\n")
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   330
	       val iod = getInIoDesc fromStr
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   331
	   in 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   332
	     if isSome iod 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   333
	     then 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   334
	       let val pd = OS.IO.pollDesc (valOf iod)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   335
	       in 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   336
	       if isSome pd then 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   337
		   let val pd' = OS.IO.pollIn (valOf pd)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   338
		       val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   339
		   in
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   340
		      if null pdl 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   341
		      then
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   342
			(File.append (File.tmp_path (Path.basic"child_poll_res")) "Null pdl\n"; 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   343
			 NONE)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   344
		      else if OS.IO.isIn (hd pdl)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   345
		      then
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   346
			   let val inval =  (TextIO.inputLine fromStr)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   347
			       val _ = File.append (File.tmp_path (Path.basic "child_poll_res")) (inval^"\n")
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   348
			   in SOME inval end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   349
		      else
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   350
                        (File.append (File.tmp_path (Path.basic"child_poll_res")) "Null pdl \n";
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   351
                         NONE)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   352
		   end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   353
		 else NONE
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   354
		 end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   355
	     else NONE
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   356
	end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   357
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   358
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   359
	(****************************************************************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   360
	(* Check all vampire processes currently running for output                 *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   361
	(****************************************************************************) 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   362
						   (*********************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   363
	 fun checkChildren ([], toParentStr) = []  (*** no children to check ********)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   364
						   (*********************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   365
	 |   checkChildren ((childProc::otherChildren), toParentStr) = 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   366
	       let val _ = File.append (File.tmp_path (Path.basic "child_check")) 
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   367
			      ("In check child, length of queue:"^
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   368
			       string_of_int (length (childProc::otherChildren)))
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   369
		   val (childInput,childOutput) =  cmdstreamsOf childProc
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   370
		   val child_handle= cmdchildHandle childProc
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   371
		   (* childCmd is the .dfg file that the problem is in *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   372
		   val childCmd = fst(snd (cmdchildInfo childProc))
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   373
		   val _ = File.append (File.tmp_path (Path.basic "child_check")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   374
			      ("\nchildCmd = " ^ childCmd)
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   375
		   (* now get the number of the subgoal from the filename *)
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   376
		   val path_parts = String.tokens(fn c => c = #"/") childCmd
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   377
		   val digits = String.translate 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   378
		                  (fn c => if Char.isDigit c then str c else "")
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17235
diff changeset
   379
		                  (List.last path_parts);
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   380
		   val sg_num =
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   381
		     (case Int.fromString digits of SOME n => n
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   382
                        | NONE => (File.append (File.tmp_path (Path.basic "child_check")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   383
                                   "\nWatcher could not read subgoal nunber!!";
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   384
                                   raise ERROR));
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   385
		   val childIncoming = pollChildInput childInput
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   386
		   val _ = File.append (File.tmp_path (Path.basic "child_check")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   387
			         "\nfinished polling child"
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   388
		   val parentID = Posix.ProcEnv.getppid()
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   389
		   val prover = cmdProver childProc
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   390
		   val prems_string = prems_string_of thm
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   391
		   val goalstring = cmdGoal childProc							
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   392
		   val _ =  File.append (File.tmp_path (Path.basic "child_check")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   393
		             ("\nsubgoals forked to checkChildren: " ^ 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   394
		              space_implode "\n" [prems_string,prover,goalstring])
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   395
	       in 
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   396
		 if isSome childIncoming
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   397
		 then 
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   398
		   (* check here for prover label on child*)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   399
		   let val _ = File.append (File.tmp_path (Path.basic "child_check")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   400
			         "\nInput available from childIncoming" 
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   401
		       val childDone = (case prover of
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   402
			   "vampire" => AtpCommunication.checkVampProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr)  
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   403
			    | "E" => AtpCommunication.checkEProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr)             
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   404
			  |"spass" => AtpCommunication.checkSpassProofFound(childInput, toParentStr, parentID,goalstring, childCmd, thm, sg_num,clause_arr)  )
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   405
		    in
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   406
		     if childDone
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   407
		     then (* child has found a proof and transferred it *)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   408
			(* Remove this child and go on to check others*)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   409
			(**********************************************)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   410
			(Unix.reap child_handle;
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   411
			 checkChildren(otherChildren, toParentStr))
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   412
		     else 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   413
			(**********************************************)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   414
			(* Keep this child and go on to check others  *)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   415
			(**********************************************)
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   416
		       (childProc::(checkChildren (otherChildren, toParentStr)))
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   417
		  end
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   418
		else
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   419
		  (File.append (File.tmp_path (Path.basic "child_check"))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   420
		               "No child output";
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   421
		   childProc::(checkChildren (otherChildren, toParentStr)))
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   422
	       end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   423
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   424
	
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   425
     (********************************************************************)                  
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   426
     (* call resolution processes                                        *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   427
     (* settings should be a list of strings                             *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   428
     (* e.g. ["-t 300", "-m 100000"]         (TextIO.input instr)^                            *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   429
     (* takes list of (string, string, string list, string)list proclist *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   430
     (********************************************************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   431
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   432
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   433
(*** add subgoal id num to this *)
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   434
	fun execCmds  [] procList = procList
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   435
	|   execCmds  ((prover, goalstring,proverCmd,settings,file)::cmds) procList  =
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   436
	      let val _ = File.write (File.tmp_path (Path.basic "exec_child"))  
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   437
	                    (space_implode "\n" 
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   438
	                      (["About to execute command for goal:",
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   439
	                        goalstring, proverCmd] @ settings @
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   440
	                       [file, Date.toString(Date.fromTimeLocal(Time.now()))]))
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   441
	          val childhandle:(TextIO.instream,TextIO.outstream) Unix.proc  = 
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   442
		       (Unix.execute(proverCmd, (settings@[file])))
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   443
		  val (instr, outstr) = Unix.streamsOf childhandle
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   444
		  
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   445
		  val newProcList = (CMDPROC{
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   446
				       prover = prover,
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   447
				       cmd = file,
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   448
				       goalstring = goalstring,
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   449
				       proc_handle = childhandle,
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   450
				       instr = instr,
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   451
				       outstr = outstr }) :: procList
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   452
     
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   453
		  val _ = File.append (File.tmp_path (Path.basic "exec_child")) 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   454
			    ("\nFinished at " ^
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   455
			     Date.toString(Date.fromTimeLocal(Time.now())))
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   456
	      in
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   457
		Posix.Process.sleep (Time.fromSeconds 1); 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   458
		execCmds cmds newProcList
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   459
	      end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   460
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   461
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   462
     (****************************************)                  
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   463
     (* call resolution processes remotely   *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   464
     (* settings should be a list of strings *)
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   465
     (* e.g. ["-t300", "-m100000"]         *)
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   466
     (****************************************)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   467
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   468
      (*  fun execRemoteCmds  [] procList = procList
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   469
	|   execRemoteCmds ((prover, goalstring,proverCmd ,settings,file)::cmds) procList  =  
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   470
	      let val  newProcList =  mySshExecuteToList ("/usr/bin/ssh",([prover,goalstring,"-t", "shep"]@[proverCmd]@settings@[file]), procList)
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   471
		  in
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   472
		       execRemoteCmds  cmds newProcList
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   473
		  end
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   474
*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   475
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   476
     (**********************************************)                  
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   477
     (* Watcher Loop                               *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   478
     (**********************************************)
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   479
         val iterations_left = ref 1000;  (*200 seconds, 5 iterations per sec*)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   480
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   481
	 fun keepWatching (toParentStr, fromParentStr,procList) = 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   482
	   let fun loop procList =  
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   483
		let val _ = Posix.Process.sleep (Time.fromMilliseconds 200)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   484
		    val cmdsFromIsa = pollParentInput ()
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   485
		in 
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   486
		   iterations_left := !iterations_left - 1;
17502
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   487
		   if !iterations_left = 0 
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   488
		   then (*Sadly, this code fails to terminate the watcher!*)
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   489
		    (TextIO.output(toParentStr, "Timeout: Killing proof processes!\n");
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   490
		     TextIO.flushOut toParentStr;
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   491
		     killChildren (map cmdchildHandle procList))
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   492
		   else if isSome cmdsFromIsa
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   493
		   then (*  deal with input from Isabelle *)
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   494
		     if getProofCmd(hd(valOf cmdsFromIsa)) = "Kill children" 
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   495
		     then 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   496
		       let val child_handles = map cmdchildHandle procList 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   497
		       in
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   498
			  killChildren child_handles;
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   499
			  loop []
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   500
		       end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   501
		     else
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   502
		       if length procList < 5     (********************)
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   503
		       then                        (* Execute locally  *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   504
			 let 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   505
			   val newProcList = execCmds (valOf cmdsFromIsa) procList
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   506
			   val parentID = Posix.ProcEnv.getppid()
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   507
			      val _ = File.append (File.tmp_path (Path.basic "prekeep_watch"))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   508
			      "Just execed a child\n"
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   509
			   val newProcList' = checkChildren (newProcList, toParentStr) 
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   510
			 in
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   511
			   File.append (File.tmp_path (Path.basic "keep_watch")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   512
			       "Off to keep watching...\n";
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   513
			   loop newProcList'
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   514
			 end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   515
		       else  (* Execute remotely              *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   516
			     (* (actually not remote for now )*)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   517
			 let 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   518
			   val newProcList = execCmds (valOf cmdsFromIsa) procList
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   519
			   val parentID = Posix.ProcEnv.getppid()
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   520
			   val newProcList' =checkChildren (newProcList, toParentStr) 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   521
			 in
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   522
			   loop newProcList'
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   523
			 end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   524
		   else (* No new input from Isabelle *)
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   525
		     let val newProcList = checkChildren (procList, toParentStr)
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   526
		     in
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   527
		      (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching...2\n ");
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   528
		       loop newProcList
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   529
		     end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   530
		 end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   531
	   in  
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17305
diff changeset
   532
	       loop procList
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   533
	   end
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   534
	   
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   535
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   536
	   in
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   537
	    (***************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   538
	    (*** Sort out pipes ********)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   539
	    (***************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   540
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   541
	     Posix.IO.close (#outfd p1);
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   542
	     Posix.IO.close (#infd p2);
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   543
	     Posix.IO.dup2{old = oldchildin, new = fromParent};
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   544
	     Posix.IO.close oldchildin;
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   545
	     Posix.IO.dup2{old = oldchildout, new = toParent};
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   546
	     Posix.IO.close oldchildout;
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   547
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   548
	     (***************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   549
	     (* start the watcher loop  *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   550
	     (***************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   551
	     keepWatching (toParentStr, fromParentStr, procList);
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   552
	     (****************************************************************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   553
(* fake return value - actually want the watcher to loop until killed *)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   554
	     (****************************************************************************)
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   555
	     Posix.Process.wordToPid 0w0
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   556
	   end);
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17231
diff changeset
   557
     (* end case *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   558
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   559
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   560
    val _ = TextIO.flushOut TextIO.stdOut
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   561
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   562
    (*******************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   563
    (***  set watcher going ********)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   564
    (*******************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   565
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   566
    val procList = []
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   567
    val pid = startWatcher procList
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   568
    (**************************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   569
    (* communication streams to watcher               *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   570
    (**************************************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   571
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   572
    val instr = openInFD ("_exec_in", #infd p2)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   573
    val outstr = openOutFD ("_exec_out", #outfd p1)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   574
    
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   575
    in
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   576
     (*******************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   577
     (* close the child-side fds    *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   578
     (*******************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   579
      Posix.IO.close (#outfd p2);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   580
      Posix.IO.close (#infd p1);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   581
      (* set the fds close on exec *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   582
      Posix.IO.setfd (#infd p2, Posix.IO.FD.flags [Posix.IO.FD.cloexec]);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   583
      Posix.IO.setfd (#outfd p1, Posix.IO.FD.flags [Posix.IO.FD.cloexec]);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   584
       
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   585
     (*******************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   586
     (* return value                *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   587
     (*******************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   588
      PROC{pid = pid,
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   589
	instr = instr,
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   590
	outstr = outstr
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   591
      }
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   592
   end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   593
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   594
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   595
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   596
(**********************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   597
(* Start a watcher and set up signal handlers             *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   598
(**********************************************************)
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   599
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   600
fun killWatcher pid = Posix.Process.kill(Posix.Process.K_PROC pid, Posix.Signal.kill);
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   601
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   602
val killWatcher' = killWatcher o ResLib.pidOfInt;
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   603
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15919
diff changeset
   604
fun reapWatcher(pid, instr, outstr) =
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   605
  (TextIO.closeIn instr; TextIO.closeOut outstr;
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   606
   Posix.Process.waitpid(Posix.Process.W_CHILD pid, []); ())
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   607
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   608
fun createWatcher (thm, clause_arr) =
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   609
 let val (childpid,(childin,childout)) = childInfo (setupWatcher(thm,clause_arr))
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   610
     fun decr_watched() =
17502
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   611
	  (goals_being_watched := !goals_being_watched - 1;
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   612
	   if !goals_being_watched = 0
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   613
	   then 
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   614
	     (File.append (File.tmp_path (Path.basic "reap_found"))
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   615
	       ("Reaping a watcher, childpid = "^
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   616
		LargeWord.toString (Posix.Process.pidToWord childpid)^"\n");
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   617
	      killWatcher childpid; reapWatcher (childpid,childin, childout))
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   618
	    else ())
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   619
     val _ = debug ("subgoals forked to createWatcher: "^ prems_string_of thm);
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   620
     fun proofHandler n = 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   621
       let val outcome = TextIO.inputLine childin
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   622
	   val goalstring = TextIO.inputLine childin
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   623
	   val _ = debug ("In signal handler. outcome = \"" ^ outcome ^ 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   624
		        "\"\ngoalstring = " ^ goalstring ^
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   625
		        "\ngoals_being_watched: "^ string_of_int (!goals_being_watched))
17502
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   626
       in 
8836793df947 further tidying; killing of old Watcher loops
paulson
parents: 17488
diff changeset
   627
	 if String.isPrefix "[" outcome (*indicates a proof reconstruction*)
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   628
	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   629
	       Recon_Transfer.apply_res_thm outcome goalstring;
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   630
	       Pretty.writeln(Pretty.str  (oct_char "361"));
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   631
	       decr_watched())
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   632
	 else if String.isPrefix "Invalid" outcome
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   633
	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   634
	       Pretty.writeln(Pretty.str ((Recon_Transfer.restore_linebreaks goalstring) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   635
	       ^ "is not provable"));
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   636
	       Pretty.writeln(Pretty.str  (oct_char "361"));
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   637
	       decr_watched())
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   638
	 else if String.isPrefix "Failure" outcome
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   639
	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   640
	       Pretty.writeln(Pretty.str ((Recon_Transfer.restore_linebreaks goalstring) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   641
	       ^ "proof attempt failed"));
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   642
	       Pretty.writeln(Pretty.str  (oct_char "361"));
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   643
	       decr_watched()) 
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   644
	(* print out a list of rules used from clasimpset*)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   645
	 else if String.isPrefix "Success" outcome
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   646
	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   647
	       Pretty.writeln(Pretty.str (goalstring^outcome));
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   648
	       Pretty.writeln(Pretty.str  (oct_char "361"));
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   649
	       decr_watched())
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   650
	  (* if proof translation failed *)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   651
	 else if String.isPrefix "Translation failed" outcome
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   652
	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   653
	       Pretty.writeln(Pretty.str (goalstring^(Recon_Transfer.restore_linebreaks outcome)));
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   654
	       Pretty.writeln(Pretty.str  (oct_char "361"));
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   655
	       decr_watched())
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   656
	 else  
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   657
	      (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   658
	       Pretty.writeln(Pretty.str ("System error in proof handler"));
17231
f42bc4f7afdf tidying up the Isabelle/ATP interface
paulson
parents: 17216
diff changeset
   659
	       Pretty.writeln(Pretty.str  (oct_char "361"));
17435
0eed5a1c00c1 PARTIAL conversion to Vampire8
paulson
parents: 17422
diff changeset
   660
	       decr_watched())
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   661
       end
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17435
diff changeset
   662
 in IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE proofHandler);
17216
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   663
    (childin, childout, childpid)
df66d8feec63 improved formatting
paulson
parents: 17150
diff changeset
   664
  end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   665
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   666
end (* structure Watcher *)