src/HOL/Tools/ATP/watcher.ML
changeset 17306 5cde710a8a23
parent 17305 6cef3aedd661
child 17315 5bf0e0aacc24
equal deleted inserted replaced
17305:6cef3aedd661 17306:5cde710a8a23
   326 	   val fromParentStr = openInFD ("_exec_in_parent", fromParent)
   326 	   val fromParentStr = openInFD ("_exec_in_parent", fromParent)
   327 	   val toParentStr = openOutFD ("_exec_out_parent", toParent)
   327 	   val toParentStr = openOutFD ("_exec_out_parent", toParent)
   328 	   val sign = sign_of_thm thm
   328 	   val sign = sign_of_thm thm
   329 	   val prems = prems_of thm
   329 	   val prems = prems_of thm
   330 	   val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   330 	   val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   331 	   val _ = (warning ("subgoals forked to startWatcher: "^prems_string));
   331 	   val _ = debug ("subgoals forked to startWatcher: "^prems_string);
   332 	  (* tracing *)
       
   333 	 (*val tenth_ax = fst( Array.sub(clause_arr, 1))  
       
   334 	   val tenth_ax_thms = memo_find_clause (tenth_ax, clause_tab)
       
   335 	   val clause_str = Meson.concat_with_and (map string_of_thm tenth_ax_thms)
       
   336 	   val _ = (warning ("tenth axiom in array in watcher is: "^tenth_ax))         
       
   337 	   val _ = (warning ("tenth axiom in table in watcher is: "^clause_str))         
       
   338 	   val _ = (warning ("num_of_clauses in watcher is: "^(string_of_int (num_of_clauses))) )       
       
   339 		    *)
       
   340 	   (*val goalstr = string_of_thm (the_goal)
       
   341 	    val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "goal_in_watcher")));  
       
   342 	   val _ = TextIO.output (outfile,goalstr )
       
   343 	   val _ =  TextIO.closeOut outfile*)
       
   344 	   fun killChildren [] = ()
   332 	   fun killChildren [] = ()
   345 	|      killChildren  (child_handle::children) = (killChild child_handle; killChildren children)
   333 	|      killChildren  (child_handle::children) =
       
   334 	         (killChild child_handle; killChildren children)
   346 
   335 
   347 	 (*************************************************************)
   336 	 (*************************************************************)
   348 	 (* take an instream and poll its underlying reader for input *)
   337 	 (* take an instream and poll its underlying reader for input *)
   349 	 (*************************************************************)
   338 	 (*************************************************************)
   350 
   339 
   351 	 fun pollParentInput () = 
   340 	 fun pollParentInput () = 
   352 	    let val pd = OS.IO.pollDesc (fromParentIOD)
   341 	   let val pd = OS.IO.pollDesc (fromParentIOD)
   353 	    in 
   342 	   in 
   354 	      if (isSome pd ) then 
   343 	     if isSome pd then 
   355 		  let val pd' = OS.IO.pollIn (valOf pd)
   344 		 let val pd' = OS.IO.pollIn (valOf pd)
   356 		      val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
   345 		     val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
   357 		      val _ = File.append (File.tmp_path (Path.basic "parent_poll")) 
   346 		     val _ = File.append (File.tmp_path (Path.basic "parent_poll")) 
   358 			("In parent_poll\n")	
   347 		       ("In parent_poll\n")	
   359 		  in
   348 		 in
   360 		     if null pdl 
   349 		    if null pdl 
   361 		     then
   350 		    then
   362 			NONE
   351 		       NONE
   363 		     else if (OS.IO.isIn (hd pdl)) 
   352 		    else if (OS.IO.isIn (hd pdl)) 
   364 			  then SOME (getCmds (toParentStr, fromParentStr, []))
   353 			 then SOME (getCmds (toParentStr, fromParentStr, []))
   365 			  else NONE
   354 			 else NONE
   366 		  end
   355 		 end
   367 		else NONE
   356 	       else NONE
   368 	    end
   357 	   end
   369 		 
   358 		 
   370 	  fun pollChildInput (fromStr) = 
   359 	  fun pollChildInput (fromStr) = 
   371 	    let val _ = File.append (File.tmp_path (Path.basic "child_poll")) 
   360 	   let val _ = File.append (File.tmp_path (Path.basic "child_poll")) 
   372 			  ("In child_poll\n")
   361 			 ("In child_poll\n")
   373 		val iod = getInIoDesc fromStr
   362 	       val iod = getInIoDesc fromStr
   374 	    in 
   363 	   in 
   375 	      if isSome iod 
   364 	     if isSome iod 
   376 	      then 
   365 	     then 
   377 		let val pd = OS.IO.pollDesc (valOf iod)
   366 	       let val pd = OS.IO.pollDesc (valOf iod)
   378 		in 
   367 	       in 
   379 		if (isSome pd ) then 
   368 	       if isSome pd then 
   380 		    let val pd' = OS.IO.pollIn (valOf pd)
   369 		   let val pd' = OS.IO.pollIn (valOf pd)
   381 			val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
   370 		       val pdl = OS.IO.poll ([pd'], SOME (Time.fromMilliseconds 2000)) 
   382 		    in
   371 		   in
   383 		       if null pdl 
   372 		      if null pdl 
   384 		       then
   373 		      then
   385 			 ( File.append (File.tmp_path (Path.basic "child_poll_res")) 
   374 			(File.append (File.tmp_path (Path.basic"child_poll_res")) "Null pdl\n"; 
   386 			  ("Null pdl \n");NONE)
   375 			 NONE)
   387 		       else if (OS.IO.isIn (hd pdl)) 
   376 		      else if OS.IO.isIn (hd pdl)
   388 			    then
   377 		      then
   389 				(let val inval =  (TextIO.inputLine fromStr)
   378 			   let val inval =  (TextIO.inputLine fromStr)
   390 				     val _ = File.append (File.tmp_path (Path.basic "child_poll_res")) (inval^"\n")
   379 			       val _ = File.append (File.tmp_path (Path.basic "child_poll_res")) (inval^"\n")
   391 				 in
   380 			   in SOME inval end
   392 				       SOME inval
   381 		      else
   393 				 end)
   382                         (File.append (File.tmp_path (Path.basic"child_poll_res")) "Null pdl \n";
   394 			    else
   383                          NONE)
   395 				  ( File.append (File.tmp_path (Path.basic "child_poll_res")) 
   384 		   end
   396 			  ("Null pdl \n");NONE)
   385 		 else NONE
   397 		    end
   386 		 end
   398 		  else  NONE
   387 	     else NONE
   399 		  end
       
   400 	      else NONE
       
   401 	end
   388 	end
   402 
   389 
   403 
   390 
   404 	(****************************************************************************)
   391 	(****************************************************************************)
   405 	(* Check all vampire processes currently running for output                 *)
   392 	(* Check all vampire processes currently running for output                 *)
   432 		   val prover = cmdProver childProc
   419 		   val prover = cmdProver childProc
   433 		   val thmstring = cmdThm childProc
   420 		   val thmstring = cmdThm childProc
   434 		   val sign = sign_of_thm thm
   421 		   val sign = sign_of_thm thm
   435 		   val prems = prems_of thm
   422 		   val prems = prems_of thm
   436 		   val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   423 		   val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   437 		   val _ = warning("subgoals forked to checkChildren: "^prems_string)
   424 		   val _ = debug("subgoals forked to checkChildren: "^prems_string)
   438 		   val goalstring = cmdGoal childProc							
   425 		   val goalstring = cmdGoal childProc							
   439 		   val _ = File.append (File.tmp_path (Path.basic "child_comms")) 
   426 		   val _ = File.append (File.tmp_path (Path.basic "child_comms")) 
   440 			      (prover^thmstring^goalstring^childCmd^"\n")
   427 			      (prover^thmstring^goalstring^childCmd^"\n")
   441 	       in 
   428 	       in 
   442 		 if (isSome childIncoming) 
   429 		 if isSome childIncoming
   443 		 then 
   430 		 then 
   444 		     (* check here for prover label on child*)
   431 		   (* check here for prover label on child*)
   445 		     let val _ = File.write (File.tmp_path (Path.basic "child_incoming")) 
   432 		   let val _ = File.write (File.tmp_path (Path.basic "child_incoming")) 
   446 				("subgoals forked to checkChildren:"^
   433 			      ("subgoals forked to checkChildren:"^
   447 				prems_string^prover^thmstring^goalstring^childCmd) 
   434 			      prems_string^prover^thmstring^goalstring^childCmd) 
   448 			 val childDone = (case prover of
   435 		       val childDone = (case prover of
   449 			     "vampire" => (VampComm.checkVampProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses) )     
   436 			   "vampire" => VampComm.checkVampProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses)  
   450                               | "E" => (EComm.checkEProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses) )              
   437 			    | "E" => EComm.checkEProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses)             
   451 			    |"spass" => (SpassComm.checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses)     ) )
   438 			  |"spass" => SpassComm.checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd, thm, sg_num,clause_arr, num_of_clauses)  )
   452 		      in
   439 		    in
   453 		       if childDone      (**********************************************)
   440 		     if childDone      (**********************************************)
   454 		       then (* child has found a proof and transferred it *)
   441 		     then (* child has found a proof and transferred it *)
   455 			  (* Remove this child and go on to check others*)
   442 			(* Remove this child and go on to check others*)
   456 			  (**********************************************)
   443 			(**********************************************)
   457 			  (Unix.reap child_handle;
   444 			(Unix.reap child_handle;
   458 			   checkChildren(otherChildren, toParentStr))
   445 			 checkChildren(otherChildren, toParentStr))
   459 		       else 
   446 		     else 
   460 			  (**********************************************)
   447 			(**********************************************)
   461 			  (* Keep this child and go on to check others  *)
   448 			(* Keep this child and go on to check others  *)
   462 			  (**********************************************)
   449 			(**********************************************)
   463 			 (childProc::(checkChildren (otherChildren, toParentStr)))
   450 		       (childProc::(checkChildren (otherChildren, toParentStr)))
   464 		    end
   451 		  end
   465 		  else
   452 		else
   466 		    (File.append (File.tmp_path (Path.basic "child_incoming")) "No child output ";
   453 		  (File.append (File.tmp_path (Path.basic "child_incoming")) "No child output ";
   467 		     childProc::(checkChildren (otherChildren, toParentStr)))
   454 		   childProc::(checkChildren (otherChildren, toParentStr)))
   468 	       end
   455 	       end
   469 
   456 
   470 	
   457 	
   471      (********************************************************************)                  
   458      (********************************************************************)                  
   472      (* call resolution processes                                        *)
   459      (* call resolution processes                                        *)
   478 
   465 
   479 (*** add subgoal id num to this *)
   466 (*** add subgoal id num to this *)
   480 	fun execCmds  [] procList = procList
   467 	fun execCmds  [] procList = procList
   481 	|   execCmds  ((prover, thmstring,goalstring,proverCmd,settings,file)::cmds) procList  =             let val _ = File.append (File.tmp_path (Path.basic "pre_exec_child"))  ("\nAbout to execute command for goal:\n"^goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
   468 	|   execCmds  ((prover, thmstring,goalstring,proverCmd,settings,file)::cmds) procList  =             let val _ = File.append (File.tmp_path (Path.basic "pre_exec_child"))  ("\nAbout to execute command for goal:\n"^goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
   482 	  in 
   469 	  in 
   483 	    if (prover = "spass") 
   470 	    if prover = "spass"
   484 	    then 
   471 	    then 
   485 	      let val childhandle:(TextIO.instream,TextIO.outstream) Unix.proc  = 
   472 	      let val childhandle:(TextIO.instream,TextIO.outstream) Unix.proc  = 
   486 		       (Unix.execute(proverCmd, (["-FullRed=0"]@settings@[file])))
   473 		       (Unix.execute(proverCmd, (["-FullRed=0"]@settings@[file])))
   487 		  val (instr, outstr) = Unix.streamsOf childhandle
   474 		  val (instr, outstr) = Unix.streamsOf childhandle
   488 		  val newProcList =    (((CMDPROC{
   475 		  val newProcList =    (((CMDPROC{
   493 				       proc_handle = childhandle,
   480 				       proc_handle = childhandle,
   494 				       instr = instr,
   481 				       instr = instr,
   495 				       outstr = outstr })::procList))
   482 				       outstr = outstr })::procList))
   496 		   val _ = File.append (File.tmp_path (Path.basic "exec_child"))  
   483 		   val _ = File.append (File.tmp_path (Path.basic "exec_child"))  
   497 			("\nexecuting command for goal:\n"^
   484 			("\nexecuting command for goal:\n"^
   498 			 goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
   485 			 goalstring^proverCmd^(concat settings)^file^
       
   486 			 " at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
   499 	      in
   487 	      in
   500 		 Posix.Process.sleep (Time.fromSeconds 1);
   488 		 Posix.Process.sleep (Time.fromSeconds 1);
   501 		 execCmds cmds newProcList
   489 		 execCmds cmds newProcList
   502 	      end
   490 	      end
   503 	    else 
   491 	    else 
   544 
   532 
   545 
   533 
   546      (**********************************************)                  
   534      (**********************************************)                  
   547      (* Watcher Loop                               *)
   535      (* Watcher Loop                               *)
   548      (**********************************************)
   536      (**********************************************)
       
   537          val iterations_left = ref 1000;  (*200 seconds, 5 iterations per sec*)
   549 
   538 
   550 	 fun keepWatching (toParentStr, fromParentStr,procList) = 
   539 	 fun keepWatching (toParentStr, fromParentStr,procList) = 
   551 	   let fun loop (procList) =  
   540 	   let fun loop (procList) =  
   552 		let val _ = Posix.Process.sleep (Time.fromMilliseconds 200)
   541 		let val _ = Posix.Process.sleep (Time.fromMilliseconds 200)
   553 		    val cmdsFromIsa = pollParentInput ()
   542 		    val cmdsFromIsa = pollParentInput ()
   554 		    fun killchildHandler (n:int)  = 
   543 		    fun killchildHandler ()  = 
   555 			  (TextIO.output(toParentStr, "Killing child proof processes!\n");
   544 			  (TextIO.output(toParentStr, "Timeout: Killing proof processes!\n");
   556 			   TextIO.flushOut toParentStr;
   545 			   TextIO.flushOut toParentStr;
   557 			   killChildren (map (cmdchildHandle) procList);
   546 			   killChildren (map (cmdchildHandle) procList);
   558 			   ())
   547 			   ())
   559 		in 
   548 		in 
   560 		   (*Signal.signal (Posix.Signal.usr2, Signal.SIG_HANDLE killchildHandler);*)
   549 		   (*Signal.signal (Posix.Signal.usr2, Signal.SIG_HANDLE killchildHandler);*)
   561 								      (**********************************)
   550 		   iterations_left := !iterations_left - 1;
   562 		   if (isSome cmdsFromIsa) 
   551 		   if !iterations_left = 0 then killchildHandler ()
       
   552 		   else if isSome cmdsFromIsa
   563 		   then (*  deal with input from Isabelle *)
   553 		   then (*  deal with input from Isabelle *)
   564 		     if (getProofCmd(hd(valOf cmdsFromIsa)) = "Kill children" )
   554 		     if getProofCmd(hd(valOf cmdsFromIsa)) = "Kill children" 
   565 		     then 
   555 		     then 
   566 		       let val child_handles = map cmdchildHandle procList 
   556 		       let val child_handles = map cmdchildHandle procList 
   567 		       in
   557 		       in
   568 			  killChildren child_handles;
   558 			  killChildren child_handles;
   569 			  (*Posix.Process.kill(Posix.Process.K_PROC (Posix.ProcEnv.getppid()), Posix.Signal.usr2);*)    
   559 			  (*Posix.Process.kill(Posix.Process.K_PROC (Posix.ProcEnv.getppid()), Posix.Signal.usr2);*)    
   570 			  loop ([])
   560 			  loop []
   571 		       end
   561 		       end
   572 		     else
   562 		     else
   573 		       if ((length procList)<10)    (********************)
   563 		       if length procList < 5     (********************)
   574 		       then                        (* Execute locally  *)
   564 		       then                        (* Execute locally  *)
   575 			 let 
   565 			 let 
   576 			   val newProcList = execCmds (valOf cmdsFromIsa) procList
   566 			   val newProcList = execCmds (valOf cmdsFromIsa) procList
   577 			   val parentID = Posix.ProcEnv.getppid()
   567 			   val parentID = Posix.ProcEnv.getppid()
   578 			      val _ = (File.append (File.tmp_path (Path.basic "prekeep_watch")) "Just execed a child\n ")
   568 			      val _ = (File.append (File.tmp_path (Path.basic "prekeep_watch")) "Just execed a child\n ")
   579 			   val newProcList' =checkChildren (newProcList, toParentStr) 
   569 			   val newProcList' =checkChildren (newProcList, toParentStr) 
   580 
   570 
   581 			   val _ = warning("off to keep watching...")
   571 			   val _ = debug("off to keep watching...")
   582 			  val _ = (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching...\n ")
   572 			  val _ = (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching...\n ")
   583 			 in
   573 			 in
   584 			   loop (newProcList') 
   574 			   loop newProcList'
   585 			 end
   575 			 end
   586 		       else  (* Execute remotely              *)
   576 		       else  (* Execute remotely              *)
   587 			     (* (actually not remote for now )*)
   577 			     (* (actually not remote for now )*)
   588 			 let 
   578 			 let 
   589 			   val newProcList = execCmds (valOf cmdsFromIsa) procList
   579 			   val newProcList = execCmds (valOf cmdsFromIsa) procList
   590 			   val parentID = Posix.ProcEnv.getppid()
   580 			   val parentID = Posix.ProcEnv.getppid()
   591 			   val newProcList' =checkChildren (newProcList, toParentStr) 
   581 			   val newProcList' =checkChildren (newProcList, toParentStr) 
   592 			 in
   582 			 in
   593 			   loop (newProcList') 
   583 			   loop newProcList'
   594 			 end
   584 			 end
   595 		   else (* No new input from Isabelle *)
   585 		   else (* No new input from Isabelle *)
   596 		     let val newProcList = checkChildren ((procList), toParentStr)
   586 		     let val newProcList = checkChildren ((procList), toParentStr)
   597 		     in
   587 		     in
   598 		      (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching.2..\n ");
   588 		      (File.append (File.tmp_path (Path.basic "keep_watch")) "Off to keep watching.2..\n ");
   599 		       loop (newProcList)
   589 		       loop newProcList
   600 		     end
   590 		     end
   601 		 end
   591 		 end
   602 	   in  
   592 	   in  
   603 	       loop (procList)
   593 	       loop procList
   604 	   end
   594 	   end
   605 	   
   595 	   
   606 
   596 
   607 	   in
   597 	   in
   608 	    (***************************)
   598 	    (***************************)
   676       val (_, status) = Posix.Process.waitpid(Posix.Process.W_CHILD pid, [])
   666       val (_, status) = Posix.Process.waitpid(Posix.Process.W_CHILD pid, [])
   677   in
   667   in
   678 	  status
   668 	  status
   679   end
   669   end
   680 
   670 
   681 fun createWatcher (thm,clause_arr, ( num_of_clauses:int)) =
   671 
       
   672 fun createWatcher (thm,clause_arr, num_of_clauses) =
   682  let val mychild = childInfo (setupWatcher(thm,clause_arr,  num_of_clauses))
   673  let val mychild = childInfo (setupWatcher(thm,clause_arr,  num_of_clauses))
   683      val streams = snd mychild
   674      val streams = snd mychild
   684      val childin = fst streams
   675      val childin = fst streams
   685      val childout = snd streams
   676      val childout = snd streams
   686      val childpid = fst mychild
   677      val childpid = fst mychild
   687      val sign = sign_of_thm thm
   678      val sign = sign_of_thm thm
   688      val prems = prems_of thm
   679      val prems = prems_of thm
   689      val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   680      val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
   690      val _ = (warning ("subgoals forked to createWatcher: "^prems_string));
   681      val _ = debug ("subgoals forked to createWatcher: "^prems_string);
       
   682 (*FIXME: do we need an E proofHandler??*)
   691      fun vampire_proofHandler (n) =
   683      fun vampire_proofHandler (n) =
   692 	(Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   684 	(Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   693 	 VampComm.getVampInput childin; Pretty.writeln(Pretty.str (oct_char "361")))               
   685 	 VampComm.getVampInput childin; Pretty.writeln(Pretty.str (oct_char "361")))               
   694      fun spass_proofHandler (n) = (
   686      fun spass_proofHandler (n) = (
   695        let val  outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "foo_signal1")));
   687        let val _ = File.append (File.tmp_path (Path.basic "spass_signal_in"))
   696 	   val _ = TextIO.output (outfile, ("In signal handler now\n"))
   688                                "Starting SPASS signal handler\n"
   697 	   val _ =  TextIO.closeOut outfile
       
   698 	   val (reconstr, goalstring, thmstring) = SpassComm.getSpassInput childin
   689 	   val (reconstr, goalstring, thmstring) = SpassComm.getSpassInput childin
   699 	   val  outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "foo_signal")));
   690 	   val _ = File.append (File.tmp_path (Path.basic "spass_signal_out"))
   700    
   691 		       ("In SPASS signal handler "^reconstr^thmstring^goalstring^
   701 	   val _ = TextIO.output (outfile, ("In signal handler  "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched))))
   692 		       "goals_being_watched: "^ string_of_int (!goals_being_watched))
   702 	   val _ =  TextIO.closeOut outfile
       
   703        in (* if a proof has been found and sent back as a reconstruction proof *)
   693        in (* if a proof has been found and sent back as a reconstruction proof *)
   704 	 if substring (reconstr, 0,1) = "["
   694 	 if substring (reconstr, 0,1) = "["
   705 	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   695 	 then (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   706 	       Recon_Transfer.apply_res_thm reconstr goalstring;
   696 	       Recon_Transfer.apply_res_thm reconstr goalstring;
   707 	       Pretty.writeln(Pretty.str  (oct_char "361"));
   697 	       Pretty.writeln(Pretty.str  (oct_char "361"));
   708 	       
   698 	       
   709 	       goals_being_watched := ((!goals_being_watched) - 1);
   699 	       goals_being_watched := (!goals_being_watched) - 1;
   710        
   700        
   711 	       if (!goals_being_watched) = 0
   701 	       if !goals_being_watched = 0
   712 	       then 
   702 	       then 
   713 		  let val _ = File.write (File.tmp_path (Path.basic "foo_reap_found"))
   703 		  let val _ = File.write (File.tmp_path (Path.basic "reap_found"))
   714                                    ("Reaping a watcher, goals watched is: "^
   704                                    ("Reaping a watcher, goals watched now "^
   715                                     (string_of_int (!goals_being_watched))^"\n")
   705                                     string_of_int (!goals_being_watched)^"\n")
   716 		   in
   706 		   in
   717 		       killWatcher (childpid); reapWatcher (childpid,childin, childout); ()
   707 		       killWatcher childpid; reapWatcher (childpid,childin, childout); ()
   718 		   end
   708 		   end
   719 		else () )
   709 		else () )
   720 	 (* if there's no proof, but a message from Spass *)
   710 	 (* if there's no proof, but a message from Spass *)
   721 	 else if substring (reconstr, 0,5) = "SPASS"
   711 	 else if substring (reconstr, 0,5) = "SPASS"
   722 	 then (goals_being_watched := (!goals_being_watched) -1;
   712 	 then (goals_being_watched := (!goals_being_watched) -1;