src/HOL/Tools/ATP/watcher.ML
changeset 15702 2677db44c795
parent 15684 5ec4d21889d6
child 15774 9df37a0e935d
equal deleted inserted replaced
15701:63f6614f95dc 15702:2677db44c795
    17 use "VampireCommunication";
    17 use "VampireCommunication";
    18 use "SpassCommunication";
    18 use "SpassCommunication";
    19 use "modUnix";*)
    19 use "modUnix";*)
    20 (*use "/homes/clq20/Jia_Code/TransStartIsar";*)
    20 (*use "/homes/clq20/Jia_Code/TransStartIsar";*)
    21 
    21 
    22 use "~~/src/HOL/Tools/ATP/VampireCommunication.ML";
       
    23 use "~~/src/HOL/Tools/ATP/SpassCommunication.ML";
       
    24 
       
    25 
       
    26 use "~~/src/HOL/Tools/ATP/modUnix.ML";
       
    27 
       
    28 
    22 
    29 structure Watcher: WATCHER =
    23 structure Watcher: WATCHER =
    30   struct
    24   struct
    31 
    25 
    32 fun fst (a,b) = a;
       
    33 fun snd (a,b) = b;
       
    34 
       
    35 val goals_being_watched = ref 0;
    26 val goals_being_watched = ref 0;
    36 
       
    37 fun remove y [] = []
       
    38 |   remove y (x::xs) = (if y = x 
       
    39                        then 
       
    40                            remove y xs 
       
    41                        else ((x::(remove y  xs))))
       
    42 
    27 
    43 
    28 
    44 
    29 
    45 fun sendOutput (outstr,str) = (TextIO.outputSubstr (outstr, (Substring.all str));TextIO.flushOut outstr);
    30 fun sendOutput (outstr,str) = (TextIO.outputSubstr (outstr, (Substring.all str));TextIO.flushOut outstr);
    46 
    31 
   228 (**************************************************************)
   213 (**************************************************************)
   229 
   214 
   230 
   215 
   231 fun getInIoDesc someInstr = 
   216 fun getInIoDesc someInstr = 
   232     let val (rd, buf) = TextIO.StreamIO.getReader(TextIO.getInstream someInstr)
   217     let val (rd, buf) = TextIO.StreamIO.getReader(TextIO.getInstream someInstr)
   233         val _ = print (TextIO.stdOut, buf)
   218         val _ = TextIO.output (TextIO.stdOut, buf)
   234         val ioDesc = 
   219         val ioDesc = 
   235 	    case rd
   220 	    case rd
   236 	      of TextPrimIO.RD{ioDesc = SOME iod, ...} =>SOME iod
   221 	      of TextPrimIO.RD{ioDesc = SOME iod, ...} =>SOME iod
   237 	       | _ => NONE
   222 	       | _ => NONE
   238      in (* since getting the reader will have terminated the stream, we need
   223      in (* since getting the reader will have terminated the stream, we need
   582 			   val streams =snd mychild
   567 			   val streams =snd mychild
   583                            val childin = fst streams
   568                            val childin = fst streams
   584                            val childout = snd streams
   569                            val childout = snd streams
   585                            val childpid = fst mychild
   570                            val childpid = fst mychild
   586                            
   571                            
   587                            fun vampire_proofHandler (n:int) =
   572                            fun vampire_proofHandler (n) =
   588                            (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   573                            (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")])));
   589                            getVampInput childin; Pretty.writeln(Pretty.str  (oct_char "361"));() )                   
   574                            getVampInput childin; Pretty.writeln(Pretty.str  (oct_char "361"));() )                   
   590                           
   575                           
   591                           (* fun spass_proofHandler (n:int) = (
   576                           (* fun spass_proofHandler (n:int) = (
   592                                                       let val (reconstr, thmstring, goalstring) = getSpassInput childin
   577                                                       let val (reconstr, thmstring, goalstring) = getSpassInput childin
   634                                                              Pretty.writeln(Pretty.str  (oct_char "361"));
   619                                                              Pretty.writeln(Pretty.str  (oct_char "361"));
   635                                                              (*killWatcher childpid; *) reap (childpid,childin, childout);()   
   620                                                              (*killWatcher childpid; *) reap (childpid,childin, childout);()   
   636                                                       end )
   621                                                       end )
   637 *)
   622 *)
   638 
   623 
   639 fun spass_proofHandler (n:int) = (
   624 fun spass_proofHandler (n) = (
   640                                  let  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal1")));
   625                                  let  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal1")));
   641                                       val _ = TextIO.output (outfile, ("In signal handler now\n"))
   626                                       val _ = TextIO.output (outfile, ("In signal handler now\n"))
   642                                       val _ =  TextIO.closeOut outfile
   627                                       val _ =  TextIO.closeOut outfile
   643                                       val (reconstr, thmstring, goalstring) = getSpassInput childin
   628                                       val (reconstr, thmstring, goalstring) = getSpassInput childin
   644                                       val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "foo_signal")));
   629                                       val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "foo_signal")));
   713                                        end)
   698                                        end)
   714 
   699 
   715 
   700 
   716                         
   701                         
   717                        in 
   702                        in 
   718                           Signal.signal (Posix.Signal.usr1, Signal.SIG_HANDLE vampire_proofHandler);
   703                           IsaSignal.signal (IsaSignal.usr1, IsaSignal.SIG_HANDLE vampire_proofHandler);
   719                           Signal.signal (Posix.Signal.usr2, Signal.SIG_HANDLE spass_proofHandler);
   704                           IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE spass_proofHandler);
   720                           (childin, childout, childpid)
   705                           (childin, childout, childpid)
   721 
   706 
   722                        end
   707                        end
   723 
   708 
   724 
   709