143 probfile) :: args) = |
143 probfile) :: args) = |
144 let val _ = trace (space_implode "\n" |
144 let val _ = trace (space_implode "\n" |
145 (["\ncallResProvers:",prover,goalstring,proverCmd,settings, |
145 (["\ncallResProvers:",prover,goalstring,proverCmd,settings, |
146 probfile])) |
146 probfile])) |
147 in TextIO.output (toWatcherStr, |
147 in TextIO.output (toWatcherStr, |
148 (prover^"$"^goalstring^"$"^proverCmd^"$"^ |
148 prover^"$"^proverCmd^"$"^ settings^"$"^probfile^"$\n"); |
149 settings^"$"^probfile^"\n")); |
149 TextIO.output (toWatcherStr, String.toString goalstring^"\n"); |
|
150 (*goalstring is a single string literal, with all specials escaped.*) |
150 goals_being_watched := (!goals_being_watched) + 1; |
151 goals_being_watched := (!goals_being_watched) + 1; |
151 TextIO.flushOut toWatcherStr; |
152 TextIO.flushOut toWatcherStr; |
152 callResProvers (toWatcherStr,args) |
153 callResProvers (toWatcherStr,args) |
153 end |
154 end |
154 |
155 |
159 (**************************************************************) |
160 (**************************************************************) |
160 |
161 |
161 fun callSlayer toWatcherStr = (TextIO.output (toWatcherStr, "Kill vampires\n"); |
162 fun callSlayer toWatcherStr = (TextIO.output (toWatcherStr, "Kill vampires\n"); |
162 TextIO.flushOut toWatcherStr) |
163 TextIO.flushOut toWatcherStr) |
163 |
164 |
164 |
165 |
165 (**************************************************************) |
|
166 (* Remove \n token from a vampire goal filename and extract *) |
|
167 (* prover, proverCmd, settings and file from input string *) |
|
168 (**************************************************************) |
|
169 |
|
170 val remove_newlines = String.translate (fn c => if c = #"\n" then "" else str c); |
|
171 |
|
172 fun getCmd cmdStr = |
|
173 let val [prover,goalstring,proverCmd,settingstr,probfile] = |
|
174 String.tokens (fn c => c = #"$") (remove_newlines cmdStr) |
|
175 val settings = String.tokens (fn c => c = #"%") settingstr |
|
176 val _ = trace ("getCmd: " ^ cmdStr ^ |
|
177 "\nprover" ^ prover ^ " goalstr: "^goalstring^ |
|
178 "\nprovercmd: " ^ proverCmd^ |
|
179 "\nprob " ^ probfile ^ "\n\n") |
|
180 in (prover,goalstring, proverCmd, settings, probfile) end |
|
181 |
|
182 (**************************************************************) |
166 (**************************************************************) |
183 (* Get commands from Isabelle *) |
167 (* Get commands from Isabelle *) |
184 (**************************************************************) |
168 (**************************************************************) |
185 fun getCmds (toParentStr,fromParentStr, cmdList) = |
169 fun getCmds (toParentStr,fromParentStr, cmdList) = |
186 let val thisLine = TextIO.inputLine fromParentStr |
170 let val thisLine = TextIO.inputLine fromParentStr |
189 if thisLine = "End of calls\n" orelse thisLine = "" then cmdList |
173 if thisLine = "End of calls\n" orelse thisLine = "" then cmdList |
190 else if thisLine = "Kill children\n" |
174 else if thisLine = "Kill children\n" |
191 then (TextIO.output (toParentStr,thisLine ); |
175 then (TextIO.output (toParentStr,thisLine ); |
192 TextIO.flushOut toParentStr; |
176 TextIO.flushOut toParentStr; |
193 (("","","Kill children",[],"")::cmdList) ) |
177 (("","","Kill children",[],"")::cmdList) ) |
194 else let val thisCmd = getCmd thisLine |
178 else |
195 in getCmds (toParentStr, fromParentStr, thisCmd::cmdList) end |
179 let val [prover,proverCmd,settingstr,probfile,_] = |
|
180 String.tokens (fn c => c = #"$") thisLine |
|
181 val settings = String.tokens (fn c => c = #"%") settingstr |
|
182 val goalstring = TextIO.inputLine fromParentStr |
|
183 in |
|
184 trace ("\nprover: " ^ prover ^ " prover path: " ^ proverCmd^ |
|
185 " problem file: " ^ probfile ^ |
|
186 "\ngoalstring: "^goalstring); |
|
187 getCmds (toParentStr, fromParentStr, |
|
188 (prover, goalstring, proverCmd, settings, probfile)::cmdList) |
|
189 end |
196 end |
190 end |
197 |
191 |
198 |
192 |
199 (**************************************************************) |
193 (**************************************************************) |
200 (* Get Io-descriptor for polling of an input stream *) |
194 (* Get Io-descriptor for polling of an input stream *) |
315 if childIncoming |
309 if childIncoming |
316 then |
310 then |
317 (* check here for prover label on child*) |
311 (* check here for prover label on child*) |
318 let val _ = trace ("\nInput available from child: " ^ |
312 let val _ = trace ("\nInput available from child: " ^ |
319 childCmd ^ |
313 childCmd ^ |
320 "\ngoalstring is " ^ goalstring ^ "\n\n") |
314 "\ngoalstring is " ^ goalstring) |
321 val childDone = (case prover of |
315 val childDone = (case prover of |
322 "vampire" => AtpCommunication.checkVampProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr) |
316 "vampire" => AtpCommunication.checkVampProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr) |
323 | "E" => AtpCommunication.checkEProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr) |
317 | "E" => AtpCommunication.checkEProofFound(childInput, toParentStr, parentID,goalstring, childCmd, clause_arr) |
324 |"spass" => AtpCommunication.checkSpassProofFound(childInput, toParentStr, parentID,goalstring, childCmd, thm, sg_num,clause_arr) ) |
318 |"spass" => AtpCommunication.checkSpassProofFound(childInput, toParentStr, parentID,goalstring, childCmd, thm, sg_num,clause_arr) ) |
325 in |
319 in |
528 killWatcher childpid; reapWatcher (childpid,childin, childout)) |
522 killWatcher childpid; reapWatcher (childpid,childin, childout)) |
529 else ()) |
523 else ()) |
530 val _ = debug ("subgoals forked to createWatcher: "^ prems_string_of thm); |
524 val _ = debug ("subgoals forked to createWatcher: "^ prems_string_of thm); |
531 fun proofHandler n = |
525 fun proofHandler n = |
532 let val outcome = TextIO.inputLine childin |
526 let val outcome = TextIO.inputLine childin |
533 val goalstring = TextIO.inputLine childin |
527 val goalstring = valOf (String.fromString (TextIO.inputLine childin)) |
534 val _ = debug ("In signal handler. outcome = \"" ^ outcome ^ |
528 val _ = debug ("In signal handler. outcome = \"" ^ outcome ^ |
535 "\"\ngoalstring = " ^ goalstring ^ |
529 "\"\ngoalstring = " ^ goalstring ^ |
536 "\ngoals_being_watched: "^ Int.toString (!goals_being_watched)) |
530 "\ngoals_being_watched: "^ Int.toString (!goals_being_watched)) |
537 in |
531 in |
538 if String.isPrefix "[" outcome (*indicates a proof reconstruction*) |
532 if String.isPrefix "[" outcome (*indicates a proof reconstruction*) |
539 then (priority (Recon_Transfer.apply_res_thm outcome goalstring); |
533 then (priority (Recon_Transfer.apply_res_thm outcome goalstring); |
540 decr_watched()) |
534 decr_watched()) |
541 else if String.isPrefix "Invalid" outcome |
535 else if String.isPrefix "Invalid" outcome |
542 then (priority (goalstring ^ "is not provable"); |
536 then (priority ("Subgoal is not provable:\n" ^ goalstring); |
543 decr_watched()) |
537 decr_watched()) |
544 else if String.isPrefix "Failure" outcome |
538 else if String.isPrefix "Failure" outcome |
545 then (priority (goalstring ^ "proof attempt failed"); |
539 then (priority ("Proof attempt failed:\n" ^ goalstring); |
546 decr_watched()) |
540 decr_watched()) |
547 (* print out a list of rules used from clasimpset*) |
541 (* print out a list of rules used from clasimpset*) |
548 else if String.isPrefix "Success" outcome |
542 else if String.isPrefix "Success" outcome |
549 then (priority (goalstring^outcome); |
543 then (priority (outcome ^ goalstring); |
550 decr_watched()) |
544 decr_watched()) |
551 (* if proof translation failed *) |
545 (* if proof translation failed *) |
552 else if String.isPrefix "Translation failed" outcome |
546 else if String.isPrefix "Translation failed" outcome |
553 then (priority (goalstring ^ outcome); |
547 then (priority (outcome ^ goalstring); |
554 decr_watched()) |
548 decr_watched()) |
555 else (priority "System error in proof handler"; |
549 else (priority "System error in proof handler"; |
556 decr_watched()) |
550 decr_watched()) |
557 end |
551 end |
558 in IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE proofHandler); |
552 in IsaSignal.signal (IsaSignal.usr2, IsaSignal.SIG_HANDLE proofHandler); |