76 then let val proofextract = extract_proof (currentString^thisLine) |
76 then let val proofextract = extract_proof (currentString^thisLine) |
77 val lemma_list = if endS = end_V8 |
77 val lemma_list = if endS = end_V8 |
78 then Recon_Transfer.vamp_lemma_list |
78 then Recon_Transfer.vamp_lemma_list |
79 else Recon_Transfer.e_lemma_list |
79 else Recon_Transfer.e_lemma_list |
80 in |
80 in |
81 trace ("\nExtracted_prf\n" ^ proofextract); |
81 trace ("\nExtracted proof:\n" ^ proofextract); |
82 lemma_list proofextract goalstring toParent ppid clause_arr |
82 lemma_list proofextract probfile toParent ppid clause_arr |
83 end |
83 end |
84 else transferInput (currentString^thisLine) |
84 else transferInput (currentString^thisLine) |
85 end |
85 end |
86 in |
86 in |
87 transferInput ""; true |
87 transferInput ""; true |
88 end handle EOF => false |
88 end handle EOF => false |
89 |
89 |
90 fun signal_parent (toParent, ppid, msg, goalstring) = |
90 |
|
91 (*The signal handler in watcher.ML must be able to read the output of this.*) |
|
92 fun signal_parent (toParent, ppid, msg, probfile) = |
91 (TextIO.output (toParent, msg); |
93 (TextIO.output (toParent, msg); |
92 TextIO.output (toParent, goalstring); |
94 TextIO.output (toParent, probfile ^ "\n"); |
93 TextIO.flushOut toParent; |
95 TextIO.flushOut toParent; |
94 trace ("\nSignalled parent: " ^ msg); |
96 trace ("\nSignalled parent: " ^ msg ^ probfile); |
95 Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2)); |
97 Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2)); |
96 |
98 |
97 (*Called from watcher. Returns true if the Vampire process has returned a verdict.*) |
99 (*Called from watcher. Returns true if the Vampire process has returned a verdict.*) |
98 fun checkVampProofFound (fromChild, toParent, ppid, goalstring, childCmd, clause_arr) = |
100 fun checkVampProofFound (fromChild, toParent, ppid, probfile, clause_arr) = |
99 let val thisLine = TextIO.inputLine fromChild |
101 let val thisLine = TextIO.inputLine fromChild |
100 in |
102 in |
101 trace thisLine; |
103 trace thisLine; |
102 if thisLine = "" |
104 if thisLine = "" |
103 then (trace "No proof output seen\n"; false) |
105 then (trace "\nNo proof output seen"; false) |
104 else if String.isPrefix start_V8 thisLine |
106 else if String.isPrefix start_V8 thisLine |
105 then |
107 then startTransfer (end_V8, fromChild, toParent, ppid, probfile, clause_arr) |
106 startTransfer (end_V8, fromChild, toParent, ppid, goalstring, childCmd, clause_arr) |
|
107 else if (String.isPrefix "Satisfiability detected" thisLine) orelse |
108 else if (String.isPrefix "Satisfiability detected" thisLine) orelse |
108 (String.isPrefix "Refutation not found" thisLine) |
109 (String.isPrefix "Refutation not found" thisLine) |
109 then (signal_parent (toParent, ppid, "Failure\n", goalstring); |
110 then (signal_parent (toParent, ppid, "Failure\n", probfile); |
110 true) |
111 true) |
111 else |
112 else |
112 checkVampProofFound (fromChild, toParent, ppid, goalstring, childCmd, clause_arr) |
113 checkVampProofFound (fromChild, toParent, ppid, probfile, clause_arr) |
113 end |
114 end |
114 |
115 |
115 |
116 |
116 (*Called from watcher. Returns true if the E process has returned a verdict.*) |
117 (*Called from watcher. Returns true if the E process has returned a verdict.*) |
117 fun checkEProofFound (fromChild, toParent, ppid,goalstring, childCmd, clause_arr) = |
118 fun checkEProofFound (fromChild, toParent, ppid, probfile, clause_arr) = |
118 let val thisLine = TextIO.inputLine fromChild |
119 let val thisLine = TextIO.inputLine fromChild |
119 in |
120 in |
120 trace thisLine; |
121 trace thisLine; |
121 if thisLine = "" |
122 if thisLine = "" |
122 then (trace "No proof output seen\n"; false) |
123 then (trace "No proof output seen\n"; false) |
123 else if String.isPrefix start_E thisLine |
124 else if String.isPrefix start_E thisLine |
124 then |
125 then |
125 startTransfer (end_E, fromChild, toParent, ppid, goalstring, childCmd, clause_arr) |
126 startTransfer (end_E, fromChild, toParent, ppid, probfile, clause_arr) |
126 else if String.isPrefix "# Problem is satisfiable" thisLine |
127 else if String.isPrefix "# Problem is satisfiable" thisLine |
127 then (signal_parent (toParent, ppid, "Invalid\n", goalstring); |
128 then (signal_parent (toParent, ppid, "Invalid\n", probfile); |
128 true) |
129 true) |
129 else if String.isPrefix "# Cannot determine problem status within resource limit" thisLine |
130 else if String.isPrefix "# Cannot determine problem status within resource limit" thisLine |
130 then (signal_parent (toParent, ppid, "Failure\n", goalstring); |
131 then (signal_parent (toParent, ppid, "Failure\n", probfile); |
131 true) |
132 true) |
132 else |
133 else |
133 checkEProofFound (fromChild, toParent, ppid, goalstring, childCmd, clause_arr) |
134 checkEProofFound (fromChild, toParent, ppid, probfile, clause_arr) |
134 end |
135 end |
135 |
136 |
136 |
137 |
137 (**********************************************************************) |
138 (**********************************************************************) |
138 (* Reconstruct the Spass proof w.r.t. thmstring (string version of *) |
139 (* Reconstruct the Spass proof w.r.t. thmstring (string version of *) |
139 (* Isabelle goal to be proved), then transfer the reconstruction *) |
140 (* Isabelle goal to be proved), then transfer the reconstruction *) |
140 (* steps as a string to the input pipe of the main Isabelle process *) |
141 (* steps as a string to the input pipe of the main Isabelle process *) |
141 (**********************************************************************) |
142 (**********************************************************************) |
142 |
143 |
143 fun spass_reconstruct_tac proofextract goalstring toParent ppid sg_num |
144 fun spass_reconstruct_tac proofextract toParent ppid probfile sg_num clause_arr = |
144 clause_arr = |
|
145 SELECT_GOAL |
145 SELECT_GOAL |
146 (EVERY1 [rtac ccontr, ObjectLogic.atomize_tac, skolemize_tac, |
146 (EVERY1 [rtac ccontr, ObjectLogic.atomize_tac, skolemize_tac, |
147 METAHYPS(fn negs => |
147 METAHYPS(fn negs => |
148 Recon_Transfer.spass_reconstruct proofextract goalstring toParent ppid negs clause_arr)]) sg_num; |
148 Recon_Transfer.spass_reconstruct proofextract probfile |
149 |
149 toParent ppid negs clause_arr)]) sg_num; |
150 |
150 |
151 fun transferSpassInput (fromChild, toParent, ppid, goalstring, |
151 |
|
152 fun transferSpassInput (fromChild, toParent, ppid, probfile, |
152 currentString, thm, sg_num, clause_arr) = |
153 currentString, thm, sg_num, clause_arr) = |
153 let val thisLine = TextIO.inputLine fromChild |
154 let val thisLine = TextIO.inputLine fromChild |
154 in |
155 in |
|
156 trace thisLine; |
155 if thisLine = "" (*end of file?*) |
157 if thisLine = "" (*end of file?*) |
156 then (trace ("\nspass_extraction_failed: " ^ currentString); |
158 then (trace ("\nspass_extraction_failed: " ^ currentString); |
157 raise EOF) |
159 raise EOF) |
158 else if String.isPrefix "--------------------------SPASS-STOP" thisLine |
160 else if String.isPrefix "--------------------------SPASS-STOP" thisLine |
159 then |
161 then |
160 let val proofextract = extract_proof (currentString^thisLine) |
162 let val proofextract = extract_proof (currentString^thisLine) |
161 in |
163 in |
162 trace ("\nextracted spass proof: " ^ proofextract); |
164 trace ("\nextracted spass proof: " ^ proofextract); |
163 if !reconstruct |
165 if !reconstruct |
164 then (spass_reconstruct_tac proofextract goalstring toParent ppid sg_num |
166 then (spass_reconstruct_tac proofextract toParent ppid probfile sg_num |
165 clause_arr thm; ()) |
167 clause_arr thm; ()) |
166 else Recon_Transfer.spass_lemma_list proofextract goalstring |
168 else Recon_Transfer.spass_lemma_list proofextract probfile toParent |
167 toParent ppid clause_arr |
169 ppid clause_arr |
168 end |
170 end |
169 else transferSpassInput (fromChild, toParent, ppid, goalstring, |
171 else transferSpassInput (fromChild, toParent, ppid, probfile, |
170 (currentString^thisLine), thm, sg_num, clause_arr) |
172 (currentString^thisLine), thm, sg_num, clause_arr) |
171 end; |
173 end; |
172 |
174 |
173 |
175 |
174 (*********************************************************************************) |
176 (*********************************************************************************) |
175 (* Inspect the output of a Spass process to see if it has found a proof, *) |
177 (* Inspect the output of a Spass process to see if it has found a proof, *) |
176 (* and if so, transfer output to the input pipe of the main Isabelle process *) |
178 (* and if so, transfer output to the input pipe of the main Isabelle process *) |
177 (*********************************************************************************) |
179 (*********************************************************************************) |
178 |
180 |
179 |
181 |
180 fun startSpassTransfer (fromChild, toParent, ppid, goalstring,childCmd, |
182 fun startSpassTransfer (fromChild, toParent, ppid, probfile, |
181 thm, sg_num,clause_arr) = |
183 thm, sg_num,clause_arr) = |
182 let val thisLine = TextIO.inputLine fromChild |
184 let val thisLine = TextIO.inputLine fromChild |
183 in |
185 in |
184 if thisLine = "" then false |
186 if thisLine = "" then false |
185 else if String.isPrefix "Here is a proof" thisLine then |
187 else if String.isPrefix "Here is a proof" thisLine then |
186 (trace ("\nabout to transfer proof, thm is " ^ string_of_thm thm); |
188 (trace ("\nabout to transfer SPASS proof\n:"); |
187 transferSpassInput (fromChild, toParent, ppid, goalstring,thisLine, |
189 transferSpassInput (fromChild, toParent, ppid, probfile, thisLine, |
188 thm, sg_num,clause_arr); |
190 thm, sg_num,clause_arr); |
189 true) handle EOF => false |
191 true) handle EOF => false |
190 else startSpassTransfer (fromChild, toParent, ppid, goalstring, |
192 else startSpassTransfer (fromChild, toParent, ppid, probfile, thm, sg_num,clause_arr) |
191 childCmd, thm, sg_num,clause_arr) |
|
192 end |
193 end |
193 |
194 |
194 |
195 |
195 (*Called from watcher. Returns true if the SPASS process has returned a verdict.*) |
196 (*Called from watcher. Returns true if the SPASS process has returned a verdict.*) |
196 fun checkSpassProofFound (fromChild, toParent, ppid, goalstring, childCmd, |
197 fun checkSpassProofFound (fromChild, toParent, ppid, probfile, |
197 thm, sg_num, clause_arr) = |
198 thm, sg_num, clause_arr) = |
198 let val thisLine = TextIO.inputLine fromChild |
199 let val thisLine = TextIO.inputLine fromChild |
199 in |
200 in |
200 trace thisLine; |
201 trace thisLine; |
201 if thisLine = "" then (trace "No proof output seen\n"; false) |
202 if thisLine = "" then (trace "No proof output seen\n"; false) |
202 else if thisLine = "SPASS beiseite: Proof found.\n" |
203 else if thisLine = "SPASS beiseite: Proof found.\n" |
203 then |
204 then |
204 startSpassTransfer (fromChild, toParent, ppid, goalstring, |
205 startSpassTransfer (fromChild, toParent, ppid, probfile, thm, sg_num, clause_arr) |
205 childCmd, thm, sg_num, clause_arr) |
|
206 else if thisLine = "SPASS beiseite: Completion found.\n" |
206 else if thisLine = "SPASS beiseite: Completion found.\n" |
207 then (signal_parent (toParent, ppid, "Invalid\n", goalstring); |
207 then (signal_parent (toParent, ppid, "Invalid\n", probfile); |
208 true) |
208 true) |
209 else if thisLine = "SPASS beiseite: Ran out of time.\n" orelse |
209 else if thisLine = "SPASS beiseite: Ran out of time.\n" orelse |
210 thisLine = "SPASS beiseite: Maximal number of loops exceeded.\n" |
210 thisLine = "SPASS beiseite: Maximal number of loops exceeded.\n" |
211 then (signal_parent (toParent, ppid, "Failure\n", goalstring); |
211 then (signal_parent (toParent, ppid, "Failure\n", probfile); |
212 true) |
212 true) |
213 else checkSpassProofFound (fromChild, toParent, ppid, goalstring, |
213 else checkSpassProofFound (fromChild, toParent, ppid, probfile, thm, sg_num, clause_arr) |
214 childCmd, thm, sg_num, clause_arr) |
|
215 end |
214 end |
216 |
215 |
217 end; |
216 end; |