| author | nipkow |
| Thu, 07 Jul 2005 12:36:56 +0200 | |
| changeset 16732 | 1bbe526a552c |
| parent 16480 | abf475cf11f2 |
| child 16839 | d7b47195ac7b |
| permissions | -rw-r--r-- |
| 15642 | 1 |
(* Title: VampireCommunication.ml |
|
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15642
diff
changeset
|
2 |
ID: $Id$ |
| 15642 | 3 |
Author: Claire Quigley |
4 |
Copyright 2004 University of Cambridge |
|
5 |
*) |
|
6 |
||
| 16480 | 7 |
(* FIXME proper structure definition *) |
8 |
||
| 15642 | 9 |
(***************************************************************************) |
10 |
(* Code to deal with the transfer of proofs from a Vampire process *) |
|
11 |
(***************************************************************************) |
|
12 |
||
13 |
(***********************************) |
|
14 |
(* Write vampire output to a file *) |
|
15 |
(***********************************) |
|
16 |
||
| 16480 | 17 |
fun logVampInput (instr, fd) = |
18 |
let val thisLine = TextIO.inputLine instr |
|
19 |
in if thisLine = "%============== End of proof. ==================\n" |
|
20 |
then TextIO.output (fd, thisLine) |
|
21 |
else ( |
|
22 |
TextIO.output (fd, thisLine); logVampInput (instr,fd)) |
|
23 |
end; |
|
| 15642 | 24 |
|
25 |
(**********************************************************************) |
|
26 |
(* Transfer the vampire output from the watcher to the input pipe of *) |
|
27 |
(* the main Isabelle process *) |
|
28 |
(**********************************************************************) |
|
29 |
||
| 16480 | 30 |
fun transferVampInput (fromChild, toParent, ppid) = |
31 |
let |
|
32 |
val thisLine = TextIO.inputLine fromChild |
|
33 |
in |
|
34 |
if (thisLine = "%============== End of proof. ==================\n" ) |
|
35 |
then ( |
|
36 |
TextIO.output (toParent, thisLine); |
|
37 |
TextIO.flushOut toParent |
|
38 |
) |
|
39 |
else ( |
|
40 |
TextIO.output (toParent, thisLine); |
|
41 |
TextIO.flushOut toParent; |
|
42 |
transferVampInput (fromChild, toParent, ppid) |
|
43 |
) |
|
44 |
end; |
|
| 15642 | 45 |
|
46 |
||
47 |
(*********************************************************************************) |
|
48 |
(* Inspect the output of a vampire process to see if it has found a proof, *) |
|
49 |
(* and if so, transfer output to the input pipe of the main Isabelle process *) |
|
50 |
(*********************************************************************************) |
|
51 |
||
| 16480 | 52 |
fun startVampireTransfer (fromChild, toParent, ppid, childCmd) = |
53 |
if (isSome (TextIO.canInput(fromChild, 5))) |
|
54 |
then |
|
55 |
( |
|
56 |
let val thisLine = TextIO.inputLine fromChild |
|
57 |
in |
|
58 |
if (thisLine = "% Proof found. Thanks to Tanya!\n" ) |
|
59 |
then |
|
60 |
( |
|
61 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr1); |
|
62 |
TextIO.output (toParent,childCmd^"\n" ); |
|
63 |
TextIO.flushOut toParent; |
|
64 |
TextIO.output (toParent, thisLine); |
|
65 |
TextIO.flushOut toParent; |
|
| 15642 | 66 |
|
| 16480 | 67 |
transferVampInput (fromChild, toParent, ppid); |
68 |
true) |
|
69 |
else if (thisLine = "% Unprovable.\n" ) |
|
70 |
then |
|
71 |
( |
|
72 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr1); |
|
73 |
TextIO.output (toParent,childCmd^"\n" ); |
|
74 |
TextIO.flushOut toParent; |
|
75 |
TextIO.output (toParent, thisLine); |
|
76 |
TextIO.flushOut toParent; |
|
| 15642 | 77 |
|
| 16480 | 78 |
true) |
79 |
else if (thisLine = "% Proof not found.\n") |
|
80 |
then |
|
81 |
(Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr1); |
|
82 |
TextIO.output (toParent,childCmd^"\n" ); |
|
83 |
TextIO.flushOut toParent; |
|
84 |
TextIO.output (toParent, thisLine); |
|
85 |
TextIO.flushOut toParent; |
|
86 |
true) |
|
87 |
else |
|
88 |
( |
|
89 |
startVampireTransfer (fromChild, toParent, ppid, childCmd) |
|
90 |
) |
|
91 |
end |
|
92 |
) |
|
93 |
else (false) |
|
| 15642 | 94 |
|
95 |
||
96 |
(***********************************************************************) |
|
97 |
(* Function used by the Isabelle process to read in a vampire proof *) |
|
98 |
(***********************************************************************) |
|
99 |
||
| 16480 | 100 |
fun getVampInput instr = |
101 |
let val thisLine = TextIO.inputLine instr |
|
102 |
in |
|
103 |
if thisLine = "%============== End of proof. ==================\n" then |
|
104 |
Pretty.writeln (Pretty.str (concat ["vampire", thisLine])) |
|
105 |
else if thisLine = "% Unprovable.\n" then |
|
106 |
Pretty.writeln (Pretty.str (concat ["vampire", thisLine])) |
|
107 |
else if thisLine = "% Proof not found.\n" then |
|
108 |
Pretty.writeln (Pretty.str (concat ["vampire", thisLine])) |
|
109 |
else |
|
110 |
(Pretty.writeln (Pretty.str (concat ["vampire", thisLine])); getVampInput instr) |
|
111 |
end; |