src/HOL/Tools/ATP/watcher.ML
changeset 16520 7a9cda53bfa2
parent 16515 7896ea4f3a87
child 16548 aa36ae6b955e
     1.1 --- a/src/HOL/Tools/ATP/watcher.ML	Tue Jun 21 21:41:08 2005 +0200
     1.2 +++ b/src/HOL/Tools/ATP/watcher.ML	Tue Jun 21 23:44:18 2005 +0200
     1.3 @@ -514,7 +514,12 @@
     1.4                          val _ = File.append (File.tmp_path (Path.basic "child_command")) 
     1.5  			           (childCmd^"\n")
     1.6  			(* now get the number of the subgoal from the filename *)
     1.7 -			val sg_num = int_of_string(ReconOrderClauses.get_nth 5 (rev(explode childCmd)))
     1.8 +			val sg_num = if (!SpassComm.spass )
     1.9 +				     then 
    1.10 +					int_of_string(ReconOrderClauses.get_nth 5 (rev(explode childCmd)))
    1.11 +				     else
    1.12 +					int_of_string(hd (rev(explode childCmd)))
    1.13 +
    1.14  			val childIncoming = pollChildInput childInput
    1.15   			val _ = File.append (File.tmp_path (Path.basic "child_check_polled")) 
    1.16  			           ("finished polling child \n")
    1.17 @@ -562,7 +567,7 @@
    1.18  	  (********************************************************************)                  
    1.19  	  (* call resolution processes                                        *)
    1.20  	  (* settings should be a list of strings                             *)
    1.21 -	  (* e.g. ["-t 300", "-m 100000"]                                     *)
    1.22 +	  (* e.g. ["-t 300", "-m 100000"]         (TextIO.input instr)^                            *)
    1.23  	  (* takes list of (string, string, string list, string)list proclist *)
    1.24  	  (********************************************************************)
    1.25  
    1.26 @@ -600,7 +605,7 @@
    1.27  						instr = instr,
    1.28  						outstr = outstr })::procList))
    1.29                
    1.30 -                           val _ = File.append (File.tmp_path (Path.basic "exec_child"))  ("executing command for goal:\n"^goalstring^proverCmd^(concat settings)^file^(TextIO.input instr)^" at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
    1.31 +                           val _ = File.append (File.tmp_path (Path.basic "exec_child"))  ("executing command for goal:\n"^goalstring^proverCmd^(concat settings)^file^" at "^(Date.toString(Date.fromTimeLocal(Time.now()))))
    1.32  		       in
    1.33  			 Posix.Process.sleep (Time.fromSeconds 1); execCmds cmds newProcList
    1.34  		       end
    1.35 @@ -789,95 +794,125 @@
    1.36  	end
    1.37  
    1.38  
    1.39 -fun createWatcher (thm,clause_arr, ( num_of_clauses:int)) =
    1.40 -  let val mychild = childInfo (setupWatcher(thm,clause_arr,  num_of_clauses))
    1.41 -      val streams =snd mychild
    1.42 -      val childin = fst streams
    1.43 -      val childout = snd streams
    1.44 -      val childpid = fst mychild
    1.45 -      val sign = sign_of_thm thm
    1.46 -      val prems = prems_of thm
    1.47 -      val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
    1.48 -      val _ = (warning ("subgoals forked to createWatcher: "^prems_string));
    1.49 -      fun vampire_proofHandler (n) =
    1.50 -	  (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
    1.51 -	  VampComm.getVampInput childin; Pretty.writeln(Pretty.str  (oct_char "361")))               
    1.52 +
    1.53 +fun createWatcher (thm,clause_arr, ( num_of_clauses:int)) = let val mychild = childInfo (setupWatcher(thm,clause_arr,  num_of_clauses))
    1.54 +			   val streams =snd mychild
    1.55 +                           val childin = fst streams
    1.56 +                           val childout = snd streams
    1.57 +                           val childpid = fst mychild
    1.58 +                           val sign = sign_of_thm thm
    1.59 +                           val prems = prems_of thm
    1.60 +                           val prems_string =  Meson.concat_with_and (map (Sign.string_of_term sign) prems) 
    1.61 +                           val _ = (warning ("subgoals forked to createWatcher: "^prems_string));
    1.62 +                           fun vampire_proofHandler (n) =
    1.63 +                           (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
    1.64 +                           VampComm.getVampInput childin; Pretty.writeln(Pretty.str  (oct_char "361"));() )               
    1.65 +                          
    1.66 +
    1.67 +fun spass_proofHandler (n) = (
    1.68 +                                 let  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_signal1")));
    1.69 +                                      val _ = TextIO.output (outfile, ("In signal handler now\n"))
    1.70 +                                      val _ =  TextIO.closeOut outfile
    1.71 +                                      val (reconstr, goalstring, thmstring) = SpassComm.getSpassInput childin
    1.72 +                                      val  outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "foo_signal")));
    1.73 +
    1.74 +                                      val _ = TextIO.output (outfile, ("In signal handler  "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched))))
    1.75 +                                      val _ =  TextIO.closeOut outfile
    1.76 +                                      in          (* if a proof has been found and sent back as a reconstruction proof *)
    1.77 +                                                  if ( (substring (reconstr, 0,1))= "[")
    1.78 +                                                  then 
    1.79  
    1.80 -      fun spass_proofHandler (n) = 
    1.81 -       let val _ = File.write (File.tmp_path (Path.basic "foo_signal1")) "In signal handler now\n"
    1.82 -	   val (reconstr, goalstring, thmstring) = SpassComm.getSpassInput childin
    1.83 -	   val _ = File.append (File.tmp_path (Path.basic "foo_signal")) 
    1.84 -		      ("In signal handler  "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched)))
    1.85 -       in  (* if a proof has been found and sent back as a reconstruction proof *)
    1.86 -	 if ( (substring (reconstr, 0,1))= "[")
    1.87 -	 then 
    1.88 -	   (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
    1.89 -	    Recon_Transfer.apply_res_thm reconstr goalstring;
    1.90 -	    Pretty.writeln(Pretty.str  (oct_char "361"));
    1.91 -	    
    1.92 -	    goals_being_watched := ((!goals_being_watched) - 1);
    1.93 -     
    1.94 -	    if ((!goals_being_watched) = 0)
    1.95 -	    then 
    1.96 -		let val _ = File.write (File.tmp_path (Path.basic "foo_reap_found"))
    1.97 -			       ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")
    1.98 -		in
    1.99 -		    killWatcher (childpid); reapWatcher (childpid,childin, childout); ()
   1.100 -		end
   1.101 -	    else ()
   1.102 -	   )
   1.103 -	 (* if there's no proof, but a message from Spass *)
   1.104 -	 else if ((substring (reconstr, 0,5))= "SPASS")
   1.105 -	 then
   1.106 -	   (goals_being_watched := (!goals_being_watched) -1;
   1.107 -	    Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.108 -	    Pretty.writeln(Pretty.str ((Recon_Transfer.restore_linebreaks goalstring)^reconstr));
   1.109 -	    Pretty.writeln(Pretty.str  (oct_char "361"));
   1.110 -	    if (!goals_being_watched = 0)
   1.111 -	    then 
   1.112 -	      (File.write (File.tmp_path (Path.basic "foo_reap_comp"))
   1.113 -				("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n");
   1.114 -	       killWatcher (childpid); reapWatcher (childpid,childin, childout); ())
   1.115 -	    else ()
   1.116 -	  ) 
   1.117 -	  (* print out a list of rules used from clasimpset*)
   1.118 -	   else if ((substring (reconstr, 0,5))= "Rules")
   1.119 -	   then
   1.120 -	     (goals_being_watched := (!goals_being_watched) -1;
   1.121 -	      Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.122 -	       Pretty.writeln(Pretty.str (goalstring^reconstr));
   1.123 -	       Pretty.writeln(Pretty.str  (oct_char "361"));
   1.124 -	       if (!goals_being_watched = 0)
   1.125 -	       then 
   1.126 -		  (File.write (File.tmp_path (Path.basic "foo_reap_comp"))
   1.127 -			       ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n");
   1.128 -		   killWatcher (childpid);  reapWatcher (childpid,childin, childout);())
   1.129 -	       else ()
   1.130 -	     )
   1.131 -	  
   1.132 -	    (* if proof translation failed *)
   1.133 -	    else if ((substring (reconstr, 0,5)) = "Proof")
   1.134 -	    then 
   1.135 -	      (goals_being_watched := (!goals_being_watched) -1;
   1.136 -	       Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.137 -		Pretty.writeln(Pretty.str (goalstring^(Recon_Transfer.restore_linebreaks reconstr)));
   1.138 -		Pretty.writeln(Pretty.str  (oct_char "361"));
   1.139 -		if (!goals_being_watched = 0)
   1.140 -		then 
   1.141 -		  (File.write (File.tmp_path (Path.basic "foo_reap_comp"))
   1.142 -			       ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n");
   1.143 -		    killWatcher (childpid); reapWatcher (childpid,childin, childout); ())
   1.144 -		else
   1.145 -		   ()
   1.146 -	     )
   1.147 -	    else  (* add something here ?*)
   1.148 -		()
   1.149 -			    
   1.150 -      end
   1.151 -	    
   1.152 -  in IsaSignal.signal (IsaSignal.usr1, IsaSignal.SIG_HANDLE vampire_proofHandler);
   1.153 -     IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE spass_proofHandler);
   1.154 -     (childin, childout, childpid)
   1.155 +                                                            (
   1.156 +                                                                 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.157 +                                                                 Recon_Transfer.apply_res_thm reconstr goalstring;
   1.158 +                                                                 Pretty.writeln(Pretty.str  (oct_char "361"));
   1.159 +                                                                 
   1.160 +                                                                 goals_being_watched := ((!goals_being_watched) - 1);
   1.161 +                                                         
   1.162 +                                                                 if ((!goals_being_watched) = 0)
   1.163 +                                                                 then 
   1.164 +                                                                    (let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_found")));
   1.165 +                                                                         val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n"))
   1.166 +                                                                         val _ =  TextIO.closeOut outfile
   1.167 +                                                                     in
   1.168 +                                                                         killWatcher (childpid); reapWatcher (childpid,childin, childout); ()
   1.169 +                                                                     end)
   1.170 +                                                                 else
   1.171 +                                                                    ()
   1.172 +                                                            )
   1.173 +                                                    (* if there's no proof, but a message from Spass *)
   1.174 +                                                    else if ((substring (reconstr, 0,5))= "SPASS")
   1.175 +                                                         then
   1.176 +                                                                 (
   1.177 +                                                                     goals_being_watched := (!goals_being_watched) -1;
   1.178 +                                                                     Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.179 +                                                                      Pretty.writeln(Pretty.str ((Recon_Transfer.restore_linebreaks goalstring)^reconstr));
   1.180 +                                                                      Pretty.writeln(Pretty.str  (oct_char "361"));
   1.181 +                                                                      if (!goals_being_watched = 0)
   1.182 +                                                                      then 
   1.183 +                                                                          (let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_comp")));
   1.184 +                                                                               val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n"))
   1.185 +                                                                               val _ =  TextIO.closeOut outfile
   1.186 +                                                                           in
   1.187 +                                                                              killWatcher (childpid); reapWatcher (childpid,childin, childout); ()
   1.188 +                                                                           end )
   1.189 +                                                                      else
   1.190 +                                                                         ()
   1.191 +                                                                ) 
   1.192 +						   (* print out a list of rules used from clasimpset*)
   1.193 +                                                    else if ((substring (reconstr, 0,5))= "Rules")
   1.194 +                                                         then
   1.195 +                                                                 (
   1.196 +                                                                     goals_being_watched := (!goals_being_watched) -1;
   1.197 +                                                                     Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.198 +                                                                      Pretty.writeln(Pretty.str (goalstring^reconstr));
   1.199 +                                                                      Pretty.writeln(Pretty.str  (oct_char "361"));
   1.200 +                                                                      if (!goals_being_watched = 0)
   1.201 +                                                                      then 
   1.202 +                                                                          (let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_reap_comp")));
   1.203 +                                                                               val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n"))
   1.204 +                                                                               val _ =  TextIO.closeOut outfile
   1.205 +                                                                           in
   1.206 +                                                                              killWatcher (childpid);  reapWatcher (childpid,childin, childout);()
   1.207 +                                                                           end )
   1.208 +                                                                      else
   1.209 +                                                                         ()
   1.210 +                                                                )
   1.211 +							
   1.212 +                                                          (* if proof translation failed *)
   1.213 +                                                          else if ((substring (reconstr, 0,5)) = "Proof")
   1.214 +                                                               then 
   1.215 +                                                                   (
   1.216 +                                                                     goals_being_watched := (!goals_being_watched) -1;
   1.217 +                                                                     Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   1.218 +                                                                      Pretty.writeln(Pretty.str (goalstring^(Recon_Transfer.restore_linebreaks reconstr)));
   1.219 +                                                                      Pretty.writeln(Pretty.str  (oct_char "361"));
   1.220 +                                                                      if (!goals_being_watched = 0)
   1.221 +                                                                      then 
   1.222 +                                                                          (let val  outfile = TextIO.openOut(File.platform_path (File.tmp_path (Path.basic "foo_reap_comp")));
   1.223 +                                                                               val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n"))
   1.224 +                                                                               val _ =  TextIO.closeOut outfile
   1.225 +                                                                           in
   1.226 +                                                                              killWatcher (childpid); reapWatcher (childpid,childin, childout); ()
   1.227 +                                                                           end )
   1.228 +                                                                      else
   1.229 +                                                                         ( )
   1.230 +                                                                      )
   1.231 +
   1.232 +
   1.233 +                                                                else  (* add something here ?*)
   1.234 +                                                                   ()
   1.235 +                                                                     
   1.236 +                                                                           
   1.237 +                                                            
   1.238 +                                       end)
   1.239 +
   1.240 +
   1.241 +                        
   1.242 +                       in IsaSignal.signal (IsaSignal.usr1, IsaSignal.SIG_HANDLE vampire_proofHandler);
   1.243 +                          IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE spass_proofHandler);
   1.244 +                          (childin, childout, childpid)
   1.245 +
   1.246  
   1.247  
   1.248    end