95 TextIO.flushOut toWatcherStr) |
95 TextIO.flushOut toWatcherStr) |
96 | callResProvers (toWatcherStr,(prover,thmstring,goalstring, proverCmd,settings,probfile)::args) = |
96 | callResProvers (toWatcherStr,(prover,thmstring,goalstring, proverCmd,settings,probfile)::args) = |
97 let |
97 let |
98 val dfg_dir = File.tmp_path (Path.basic "dfg"); |
98 val dfg_dir = File.tmp_path (Path.basic "dfg"); |
99 (* need to check here if the directory exists and, if not, create it*) |
99 (* need to check here if the directory exists and, if not, create it*) |
100 val outfile = TextIO.openAppend("thmstring_in_watcher"); |
100 val outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic"thmstring_in_watcher"))); |
101 val _ = TextIO.output (outfile, (thmstring^"\n goals_watched"^(string_of_int(!goals_being_watched))^"\n")) |
101 val _ = TextIO.output (outfile, (thmstring^"\n goals_watched"^(string_of_int(!goals_being_watched))^"\n")) |
102 val _ = TextIO.closeOut outfile |
102 val _ = TextIO.closeOut outfile |
103 val dfg_create =if File.exists dfg_dir |
103 val dfg_create =if File.exists dfg_dir |
104 then |
104 then |
105 () |
105 () |
170 |
170 |
171 val (settings, rest) = takeUntil "*" rest [] |
171 val (settings, rest) = takeUntil "*" rest [] |
172 val settings = getSettings settings [] |
172 val settings = getSettings settings [] |
173 val (file, rest) = takeUntil "*" rest [] |
173 val (file, rest) = takeUntil "*" rest [] |
174 val file = implode file |
174 val file = implode file |
175 val outfile = TextIO.openOut("sep_comms"); |
175 val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "sep_comms"))); |
176 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^proverCmd^file) ) |
176 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^proverCmd^file) ) |
177 val _ = TextIO.closeOut outfile |
177 val _ = TextIO.closeOut outfile |
178 |
178 |
179 in |
179 in |
180 (prover,thmstring,goalstring, proverCmd, settings, file) |
180 (prover,thmstring,goalstring, proverCmd, settings, file) |
246 (* Set up a Watcher Process *) |
246 (* Set up a Watcher Process *) |
247 (*************************************) |
247 (*************************************) |
248 |
248 |
249 |
249 |
250 |
250 |
251 fun setupWatcher (the_goal) = let |
251 fun setupWatcher () = let |
252 (** pipes for communication between parent and watcher **) |
252 (** pipes for communication between parent and watcher **) |
253 val p1 = Posix.IO.pipe () |
253 val p1 = Posix.IO.pipe () |
254 val p2 = Posix.IO.pipe () |
254 val p2 = Posix.IO.pipe () |
255 fun closep () = ( |
255 fun closep () = ( |
256 Posix.IO.close (#outfd p1); |
256 Posix.IO.close (#outfd p1); |
273 val oldchildout = #outfd p2 |
273 val oldchildout = #outfd p2 |
274 val toParent = Posix.FileSys.wordToFD 0w1 |
274 val toParent = Posix.FileSys.wordToFD 0w1 |
275 val fromParentIOD = Posix.FileSys.fdToIOD fromParent |
275 val fromParentIOD = Posix.FileSys.fdToIOD fromParent |
276 val fromParentStr = openInFD ("_exec_in_parent", fromParent) |
276 val fromParentStr = openInFD ("_exec_in_parent", fromParent) |
277 val toParentStr = openOutFD ("_exec_out_parent", toParent) |
277 val toParentStr = openOutFD ("_exec_out_parent", toParent) |
278 val goalstr = string_of_thm (the_goal) |
278 (*val goalstr = string_of_thm (the_goal) |
279 val outfile = TextIO.openOut("goal_in_watcher"); |
279 val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "goal_in_watcher"))); |
280 val _ = TextIO.output (outfile,goalstr ) |
280 val _ = TextIO.output (outfile,goalstr ) |
281 val _ = TextIO.closeOut outfile |
281 val _ = TextIO.closeOut outfile*) |
282 fun killChildren [] = () |
282 fun killChildren [] = () |
283 | killChildren (childPid::children) = (killChild childPid; killChildren children) |
283 | killChildren (childPid::children) = (killChild childPid; killChildren children) |
284 |
284 |
285 |
285 |
286 |
286 |
352 val childIncoming = pollChildInput childInput |
352 val childIncoming = pollChildInput childInput |
353 val parentID = Posix.ProcEnv.getppid() |
353 val parentID = Posix.ProcEnv.getppid() |
354 val prover = cmdProver childProc |
354 val prover = cmdProver childProc |
355 val thmstring = cmdThm childProc |
355 val thmstring = cmdThm childProc |
356 val goalstring = cmdGoal childProc |
356 val goalstring = cmdGoal childProc |
357 val outfile = TextIO.openOut("child_comms"); |
357 val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "child_comms"))); |
358 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^childCmd) ) |
358 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^childCmd) ) |
359 val _ = TextIO.closeOut outfile |
359 val _ = TextIO.closeOut outfile |
360 in |
360 in |
361 if (isSome childIncoming) |
361 if (isSome childIncoming) |
362 then |
362 then |
363 (* check here for prover label on child*) |
363 (* check here for prover label on child*) |
364 |
364 |
365 let val outfile = TextIO.openOut("child_incoming"); |
365 let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "child_incoming"))); |
366 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^childCmd) ) |
366 val _ = TextIO.output (outfile,(prover^thmstring^goalstring^childCmd) ) |
367 val _ = TextIO.closeOut outfile |
367 val _ = TextIO.closeOut outfile |
368 val childDone = (case prover of |
368 val childDone = (case prover of |
369 (* "vampire" => startVampireTransfer(childInput, toParentStr, parentID, childCmd) |*)"spass" => (checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd) ) ) |
369 (* "vampire" => startVampireTransfer(childInput, toParentStr, parentID, childCmd) |*)"spass" => (checkSpassProofFound(childInput, toParentStr, parentID,thmstring,goalstring, childCmd) ) ) |
370 in |
370 in |
383 (**********************************************) |
383 (**********************************************) |
384 |
384 |
385 (childProc::(checkChildren (otherChildren, toParentStr))) |
385 (childProc::(checkChildren (otherChildren, toParentStr))) |
386 end |
386 end |
387 else |
387 else |
388 let val outfile = TextIO.openAppend("child_incoming"); |
388 let val outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "child_incoming"))); |
389 val _ = TextIO.output (outfile,"No child output " ) |
389 val _ = TextIO.output (outfile,"No child output " ) |
390 val _ = TextIO.closeOut outfile |
390 val _ = TextIO.closeOut outfile |
391 in |
391 in |
392 (childProc::(checkChildren (otherChildren, toParentStr))) |
392 (childProc::(checkChildren (otherChildren, toParentStr))) |
393 end |
393 end |
576 (**********************************************************) |
576 (**********************************************************) |
577 (* Start a watcher and set up signal handlers *) |
577 (* Start a watcher and set up signal handlers *) |
578 (**********************************************************) |
578 (**********************************************************) |
579 fun killWatcher pid= killChild pid; |
579 fun killWatcher pid= killChild pid; |
580 |
580 |
581 fun createWatcher (the_goal) = let val mychild = childInfo (setupWatcher(the_goal)) |
581 fun createWatcher () = let val mychild = childInfo (setupWatcher()) |
582 val streams =snd mychild |
582 val streams =snd mychild |
583 val childin = fst streams |
583 val childin = fst streams |
584 val childout = snd streams |
584 val childout = snd streams |
585 val childpid = fst mychild |
585 val childpid = fst mychild |
586 |
586 |
588 (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
588 (Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
589 getVampInput childin; Pretty.writeln(Pretty.str (oct_char "361"));() ) |
589 getVampInput childin; Pretty.writeln(Pretty.str (oct_char "361"));() ) |
590 |
590 |
591 (* fun spass_proofHandler (n:int) = ( |
591 (* fun spass_proofHandler (n:int) = ( |
592 let val (reconstr, thmstring, goalstring) = getSpassInput childin |
592 let val (reconstr, thmstring, goalstring) = getSpassInput childin |
593 val outfile = TextIO.openOut("foo_signal"); |
593 val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal"))); |
594 |
594 |
595 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^" "^thmstring)) |
595 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^" "^thmstring)) |
596 val _ = TextIO.closeOut outfile |
596 val _ = TextIO.closeOut outfile |
597 in |
597 in |
598 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
598 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
603 |
603 |
604 |
604 |
605 (* |
605 (* |
606 |
606 |
607 fun spass_proofHandler (n:int) = ( |
607 fun spass_proofHandler (n:int) = ( |
608 let val outfile = TextIO.openOut("foo_signal1"); |
608 let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal1"))); |
609 |
609 |
610 val _ = TextIO.output (outfile, ("In signal handler now\n")) |
610 val _ = TextIO.output (outfile, ("In signal handler now\n")) |
611 val _ = TextIO.closeOut outfile |
611 val _ = TextIO.closeOut outfile |
612 val (reconstr, thmstring, goalstring) = getSpassInput childin |
612 val (reconstr, thmstring, goalstring) = getSpassInput childin |
613 val outfile = TextIO.openOut("foo_signal"); |
613 val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_signal"))); |
614 |
614 |
615 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^" "^thmstring^goalstring)) |
615 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^" "^thmstring^goalstring)) |
616 val _ = TextIO.closeOut outfile |
616 val _ = TextIO.closeOut outfile |
617 in |
617 in |
618 if ( (substring (reconstr, 0,1))= "[") |
618 if ( (substring (reconstr, 0,1))= "[") |
635 (*killWatcher childpid; *) reap (childpid,childin, childout);() |
635 (*killWatcher childpid; *) reap (childpid,childin, childout);() |
636 end ) |
636 end ) |
637 *) |
637 *) |
638 |
638 |
639 fun spass_proofHandler (n:int) = ( |
639 fun spass_proofHandler (n:int) = ( |
640 let val outfile = TextIO.openOut("foo_signal1"); |
640 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")) |
641 val _ = TextIO.output (outfile, ("In signal handler now\n")) |
642 val _ = TextIO.closeOut outfile |
642 val _ = TextIO.closeOut outfile |
643 val (reconstr, thmstring, goalstring) = getSpassInput childin |
643 val (reconstr, thmstring, goalstring) = getSpassInput childin |
644 val outfile = TextIO.openAppend("foo_signal"); |
644 val outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "foo_signal"))); |
645 |
645 |
646 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched)))) |
646 val _ = TextIO.output (outfile, ("In signal handler "^reconstr^thmstring^goalstring^"goals_being_watched is: "^(string_of_int (!goals_being_watched)))) |
647 val _ = TextIO.closeOut outfile |
647 val _ = TextIO.closeOut outfile |
648 in (* if a proof has been found and sent back as a reconstruction proof *) |
648 in (* if a proof has been found and sent back as a reconstruction proof *) |
649 if ( (substring (reconstr, 0,1))= "[") |
649 if ( (substring (reconstr, 0,1))= "[") |
656 |
656 |
657 goals_being_watched := ((!goals_being_watched) - 1); |
657 goals_being_watched := ((!goals_being_watched) - 1); |
658 |
658 |
659 if ((!goals_being_watched) = 0) |
659 if ((!goals_being_watched) = 0) |
660 then |
660 then |
661 (let val outfile = TextIO.openOut("foo_reap_found"); |
661 (let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_reap_found"))); |
662 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
662 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
663 val _ = TextIO.closeOut outfile |
663 val _ = TextIO.closeOut outfile |
664 in |
664 in |
665 reap (childpid,childin, childout); () |
665 reap (childpid,childin, childout); () |
666 end) |
666 end) |
675 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
675 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
676 Pretty.writeln(Pretty.str (goalstring^reconstr)); |
676 Pretty.writeln(Pretty.str (goalstring^reconstr)); |
677 Pretty.writeln(Pretty.str (oct_char "361")); |
677 Pretty.writeln(Pretty.str (oct_char "361")); |
678 if (!goals_being_watched = 0) |
678 if (!goals_being_watched = 0) |
679 then |
679 then |
680 (let val outfile = TextIO.openOut("foo_reap_comp"); |
680 (let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_reap_comp"))); |
681 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
681 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
682 val _ = TextIO.closeOut outfile |
682 val _ = TextIO.closeOut outfile |
683 in |
683 in |
684 reap (childpid,childin, childout); () |
684 reap (childpid,childin, childout); () |
685 end ) |
685 end ) |
694 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
694 Pretty.writeln(Pretty.str ( (concat[(oct_char "360"), (oct_char "377")]))); |
695 Pretty.writeln(Pretty.str (goalstring^reconstr)); |
695 Pretty.writeln(Pretty.str (goalstring^reconstr)); |
696 Pretty.writeln(Pretty.str (oct_char "361")); |
696 Pretty.writeln(Pretty.str (oct_char "361")); |
697 if (!goals_being_watched = 0) |
697 if (!goals_being_watched = 0) |
698 then |
698 then |
699 (let val outfile = TextIO.openOut("foo_reap_comp"); |
699 (let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_reap_comp"))); |
700 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
700 val _ = TextIO.output (outfile, ("Reaping a watcher, goals watched is: "^(string_of_int (!goals_being_watched))^"\n")) |
701 val _ = TextIO.closeOut outfile |
701 val _ = TextIO.closeOut outfile |
702 in |
702 in |
703 reap (childpid,childin, childout); () |
703 reap (childpid,childin, childout); () |
704 end ) |
704 end ) |