author | wenzelm |
Fri, 15 Dec 2006 00:08:06 +0100 | |
changeset 21858 | 05f57309170c |
parent 20826 | 32640c8956e7 |
child 21888 | c75a44597fb7 |
permissions | -rw-r--r-- |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
1 |
(* Title: VampCommunication.ml |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
2 |
ID: $Id$ |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
3 |
Author: Claire Quigley |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
4 |
Copyright 2004 University of Cambridge |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
5 |
*) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
6 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
7 |
(***************************************************************************) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
8 |
(* Code to deal with the transfer of proofs from a Vampire process *) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
9 |
(***************************************************************************) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
10 |
signature ATP_COMMUNICATION = |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
11 |
sig |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
12 |
val checkEProofFound: |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
13 |
TextIO.instream * TextIO.outstream * Posix.Process.pid * |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
14 |
string * string Array.array -> bool |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
15 |
val checkVampProofFound: |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
16 |
TextIO.instream * TextIO.outstream * Posix.Process.pid * |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
17 |
string * string Array.array -> bool |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
18 |
val checkSpassProofFound: |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
19 |
TextIO.instream * TextIO.outstream * Posix.Process.pid * |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
20 |
string * thm * int * string Array.array -> bool |
17773
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
21 |
val signal_parent: |
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
22 |
TextIO.outstream * Posix.Process.pid * string * string -> unit |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
23 |
end; |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
24 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
25 |
structure AtpCommunication : ATP_COMMUNICATION = |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
26 |
struct |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
27 |
|
17718 | 28 |
val trace_path = Path.basic "atp_trace"; |
29 |
||
30 |
fun trace s = if !Output.show_debug_msgs then File.append (File.tmp_path trace_path) s |
|
31 |
else (); |
|
32 |
||
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
33 |
exception EOF; |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
34 |
|
20762 | 35 |
|
36 |
(**** retrieve the axioms that were used in the proof ****) |
|
37 |
||
38 |
(*Get names of axioms used. Axioms are indexed from 1, while the array is indexed from 0*) |
|
39 |
fun get_axiom_names (names_arr: string array) step_nums = |
|
40 |
let fun is_axiom n = n <= Array.length names_arr |
|
41 |
fun index i = Array.sub(names_arr, i-1) |
|
42 |
val axnums = List.filter is_axiom step_nums |
|
43 |
val axnames = sort_distinct string_ord (map index axnums) |
|
44 |
in |
|
45 |
if length axnums = length step_nums then "UNSOUND!!" :: axnames |
|
46 |
else axnames |
|
47 |
end |
|
48 |
||
49 |
(*String contains multiple lines. We want those of the form |
|
50 |
"253[0:Inp] et cetera..." |
|
51 |
A list consisting of the first number in each line is returned. *) |
|
52 |
fun get_spass_linenums proofstr = |
|
53 |
let val toks = String.tokens (not o Char.isAlphaNum) |
|
54 |
fun inputno (ntok::"0"::"Inp"::_) = Int.fromString ntok |
|
55 |
| inputno _ = NONE |
|
56 |
val lines = String.tokens (fn c => c = #"\n") proofstr |
|
57 |
in List.mapPartial (inputno o toks) lines end |
|
58 |
||
59 |
fun get_axiom_names_spass proofstr names_arr = |
|
60 |
get_axiom_names names_arr (get_spass_linenums proofstr); |
|
61 |
||
62 |
(*String contains multiple lines. We want those of the form |
|
63 |
"number : ...: ...: initial..." *) |
|
64 |
fun get_e_linenums proofstr = |
|
65 |
let val fields = String.fields (fn c => c = #":") |
|
66 |
val nospaces = String.translate (fn c => if c = #" " then "" else str c) |
|
67 |
fun initial s = String.isPrefix "initial" (nospaces s) |
|
68 |
fun firstno (line :: _ :: _ :: rule :: _) = |
|
69 |
if initial rule then Int.fromString line else NONE |
|
70 |
| firstno _ = NONE |
|
71 |
val lines = String.tokens (fn c => c = #"\n") proofstr |
|
72 |
in List.mapPartial (firstno o fields) lines end |
|
73 |
||
74 |
fun get_axiom_names_e proofstr names_arr = |
|
75 |
get_axiom_names names_arr (get_e_linenums proofstr); |
|
76 |
||
77 |
(*String contains multiple lines. We want those of the form |
|
78 |
"*********** [448, input] ***********". |
|
79 |
A list consisting of the first number in each line is returned. *) |
|
80 |
fun get_vamp_linenums proofstr = |
|
81 |
let val toks = String.tokens (not o Char.isAlphaNum) |
|
82 |
fun inputno [ntok,"input"] = Int.fromString ntok |
|
83 |
| inputno _ = NONE |
|
84 |
val lines = String.tokens (fn c => c = #"\n") proofstr |
|
85 |
in List.mapPartial (inputno o toks) lines end |
|
86 |
||
87 |
fun get_axiom_names_vamp proofstr names_arr = |
|
88 |
get_axiom_names names_arr (get_vamp_linenums proofstr); |
|
89 |
||
90 |
fun rules_to_string [] = "NONE" |
|
91 |
| rules_to_string xs = space_implode " " xs |
|
92 |
||
93 |
||
94 |
(*The signal handler in watcher.ML must be able to read the output of this.*) |
|
95 |
fun prover_lemma_list_aux getax proofstr probfile toParent ppid names_arr = |
|
96 |
let val _ = trace |
|
97 |
("\n\nGetting lemma names. proofstr is " ^ proofstr ^ |
|
98 |
"\nprobfile is " ^ probfile ^ |
|
99 |
" num of clauses is " ^ string_of_int (Array.length names_arr)) |
|
100 |
val axiom_names = getax proofstr names_arr |
|
101 |
val ax_str = rules_to_string axiom_names |
|
102 |
in |
|
103 |
trace ("\nDone. Lemma list is " ^ ax_str); |
|
104 |
TextIO.output (toParent, "Success. Lemmas used in automatic proof: " ^ |
|
105 |
ax_str ^ "\n"); |
|
106 |
TextIO.output (toParent, probfile ^ "\n"); |
|
107 |
TextIO.flushOut toParent; |
|
108 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2) |
|
109 |
end |
|
110 |
handle exn => (*FIXME: exn handler is too general!*) |
|
111 |
(trace ("\nprover_lemma_list_aux: In exception handler: " ^ |
|
112 |
Toplevel.exn_message exn); |
|
113 |
TextIO.output (toParent, "Translation failed for the proof: " ^ |
|
114 |
String.toString proofstr ^ "\n"); |
|
115 |
TextIO.output (toParent, probfile); |
|
116 |
TextIO.flushOut toParent; |
|
117 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2)); |
|
118 |
||
119 |
val e_lemma_list = prover_lemma_list_aux get_axiom_names_e; |
|
120 |
||
121 |
val vamp_lemma_list = prover_lemma_list_aux get_axiom_names_vamp; |
|
122 |
||
123 |
val spass_lemma_list = prover_lemma_list_aux get_axiom_names_spass; |
|
124 |
||
125 |
||
20826 | 126 |
(**** Extracting proofs from an ATP's output ****) |
20762 | 127 |
|
20826 | 128 |
(*Return everything in s that comes before the string t*) |
129 |
fun cut_before t s = |
|
130 |
let val (s1,s2) = Substring.position t (Substring.full s) |
|
21858
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20826
diff
changeset
|
131 |
val _ = Substring.size s2 <> 0 |
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents:
20826
diff
changeset
|
132 |
orelse error "cut_before: string not found" |
20826 | 133 |
in Substring.string s2 end; |
20762 | 134 |
|
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
135 |
val start_E = "# Proof object starts here." |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
136 |
val end_E = "# Proof object ends here." |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
137 |
val start_V6 = "%================== Proof: ======================" |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
138 |
val end_V6 = "%============== End of proof. ==================" |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
139 |
val start_V8 = "=========== Refutation ==========" |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
140 |
val end_V8 = "======= End of refutation =======" |
20826 | 141 |
val end_SPASS = "Formulae used in the proof" |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
142 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
143 |
(*********************************************************************************) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
144 |
(* Inspect the output of an ATP process to see if it has found a proof, *) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
145 |
(* and if so, transfer output to the input pipe of the main Isabelle process *) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
146 |
(*********************************************************************************) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
147 |
|
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
148 |
fun startTransfer (endS, fromChild, toParent, ppid, probfile, names_arr) = |
17569 | 149 |
let fun transferInput currentString = |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
150 |
let val thisLine = TextIO.inputLine fromChild |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
151 |
in |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
152 |
if thisLine = "" (*end of file?*) |
17718 | 153 |
then (trace ("\n extraction_failed. End bracket: " ^ endS ^ |
154 |
"\naccumulated text: " ^ currentString); |
|
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
155 |
raise EOF) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
156 |
else if String.isPrefix endS thisLine |
20826 | 157 |
then let val proofextract = currentString ^ cut_before endS thisLine |
158 |
val lemma_list = if endS = end_V8 then vamp_lemma_list |
|
20762 | 159 |
else e_lemma_list |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
160 |
in |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
161 |
trace ("\nExtracted proof:\n" ^ proofextract); |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
162 |
lemma_list proofextract probfile toParent ppid names_arr |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
163 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
164 |
else transferInput (currentString^thisLine) |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
165 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
166 |
in |
17569 | 167 |
transferInput ""; true |
168 |
end handle EOF => false |
|
169 |
||
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
170 |
|
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
171 |
(*The signal handler in watcher.ML must be able to read the output of this.*) |
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
172 |
fun signal_parent (toParent, ppid, msg, probfile) = |
17569 | 173 |
(TextIO.output (toParent, msg); |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
174 |
TextIO.output (toParent, probfile ^ "\n"); |
17569 | 175 |
TextIO.flushOut toParent; |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
176 |
trace ("\nSignalled parent: " ^ msg ^ probfile); |
17773
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
177 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
178 |
(*Give the parent time to respond before possibly sending another signal*) |
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
179 |
OS.Process.sleep (Time.fromMilliseconds 600)); |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
180 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
181 |
(*Called from watcher. Returns true if the Vampire process has returned a verdict.*) |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
182 |
fun checkVampProofFound (fromChild, toParent, ppid, probfile, names_arr) = |
17569 | 183 |
let val thisLine = TextIO.inputLine fromChild |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
184 |
in |
17718 | 185 |
trace thisLine; |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
186 |
if thisLine = "" |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
187 |
then (trace "\nNo proof output seen"; false) |
17569 | 188 |
else if String.isPrefix start_V8 thisLine |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
189 |
then startTransfer (end_V8, fromChild, toParent, ppid, probfile, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
190 |
else if (String.isPrefix "Satisfiability detected" thisLine) orelse |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
191 |
(String.isPrefix "Refutation not found" thisLine) |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
192 |
then (signal_parent (toParent, ppid, "Failure\n", probfile); |
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17583
diff
changeset
|
193 |
true) |
20826 | 194 |
else checkVampProofFound (fromChild, toParent, ppid, probfile, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
195 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
196 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
197 |
(*Called from watcher. Returns true if the E process has returned a verdict.*) |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
198 |
fun checkEProofFound (fromChild, toParent, ppid, probfile, names_arr) = |
17569 | 199 |
let val thisLine = TextIO.inputLine fromChild |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
200 |
in |
17718 | 201 |
trace thisLine; |
20826 | 202 |
if thisLine = "" then (trace "\nNo proof output seen"; false) |
17569 | 203 |
else if String.isPrefix start_E thisLine |
20826 | 204 |
then startTransfer (end_E, fromChild, toParent, ppid, probfile, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
205 |
else if String.isPrefix "# Problem is satisfiable" thisLine |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
206 |
then (signal_parent (toParent, ppid, "Invalid\n", probfile); |
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17583
diff
changeset
|
207 |
true) |
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17583
diff
changeset
|
208 |
else if String.isPrefix "# Cannot determine problem status within resource limit" thisLine |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
209 |
then (signal_parent (toParent, ppid, "Failure\n", probfile); |
17690
8ba7c3cd24a8
time limit option; fixed bug concerning first line of ATP output
paulson
parents:
17583
diff
changeset
|
210 |
true) |
20826 | 211 |
else checkEProofFound (fromChild, toParent, ppid, probfile, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
212 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
213 |
|
20826 | 214 |
(*FIXME: can't these two functions be replaced by startTransfer above?*) |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
215 |
fun transferSpassInput (fromChild, toParent, ppid, probfile, |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
216 |
currentString, thm, sg_num, names_arr) = |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
217 |
let val thisLine = TextIO.inputLine fromChild |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
218 |
in |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
219 |
trace thisLine; |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
220 |
if thisLine = "" (*end of file?*) |
17718 | 221 |
then (trace ("\nspass_extraction_failed: " ^ currentString); |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
222 |
raise EOF) |
18700 | 223 |
else if String.isPrefix "Formulae used in the proof" thisLine |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
224 |
then |
20826 | 225 |
let val proofextract = currentString ^ cut_before end_SPASS thisLine |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
226 |
in |
17718 | 227 |
trace ("\nextracted spass proof: " ^ proofextract); |
20826 | 228 |
spass_lemma_list proofextract probfile toParent ppid names_arr |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
229 |
end |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
230 |
else transferSpassInput (fromChild, toParent, ppid, probfile, |
20826 | 231 |
currentString ^ thisLine, thm, sg_num, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
232 |
end; |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
233 |
|
20826 | 234 |
(*Inspect the output of a SPASS process to see if it has found a proof, |
235 |
and if so, transfer output to the input pipe of the main Isabelle process*) |
|
236 |
fun startSpassTransfer (fromChild, toParent, ppid, probfile, thm, sg_num,names_arr) = |
|
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
237 |
let val thisLine = TextIO.inputLine fromChild |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
238 |
in |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
239 |
if thisLine = "" then false |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
240 |
else if String.isPrefix "Here is a proof" thisLine then |
18700 | 241 |
(trace ("\nabout to transfer SPASS proof:\n"); |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
242 |
transferSpassInput (fromChild, toParent, ppid, probfile, thisLine, |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
243 |
thm, sg_num,names_arr); |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
244 |
true) handle EOF => false |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
245 |
else startSpassTransfer (fromChild, toParent, ppid, probfile, thm, sg_num,names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
246 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
247 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
248 |
|
17718 | 249 |
(*Called from watcher. Returns true if the SPASS process has returned a verdict.*) |
20826 | 250 |
fun checkSpassProofFound (fromChild, toParent, ppid, probfile, thm, sg_num, names_arr) = |
17718 | 251 |
let val thisLine = TextIO.inputLine fromChild |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
252 |
in |
17718 | 253 |
trace thisLine; |
17773
a7258e1020b7
more tidying. Fixed process management bugs and race condition
paulson
parents:
17772
diff
changeset
|
254 |
if thisLine = "" then (trace "\nNo proof output seen"; false) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
255 |
else if thisLine = "SPASS beiseite: Proof found.\n" |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
256 |
then |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
257 |
startSpassTransfer (fromChild, toParent, ppid, probfile, thm, sg_num, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
258 |
else if thisLine = "SPASS beiseite: Completion found.\n" |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
259 |
then (signal_parent (toParent, ppid, "Invalid\n", probfile); |
17718 | 260 |
true) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
261 |
else if thisLine = "SPASS beiseite: Ran out of time.\n" orelse |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
262 |
thisLine = "SPASS beiseite: Maximal number of loops exceeded.\n" |
17772
818cec5f82a4
major simplification: removal of the goalstring argument
paulson
parents:
17746
diff
changeset
|
263 |
then (signal_parent (toParent, ppid, "Failure\n", probfile); |
17718 | 264 |
true) |
19199
b338c218cc6e
Proof reconstruction now only takes names of theorems as input.
mengj
parents:
18700
diff
changeset
|
265 |
else checkSpassProofFound (fromChild, toParent, ppid, probfile, thm, sg_num, names_arr) |
17484
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
266 |
end |
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
267 |
|
f6a225f97f0a
simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents:
diff
changeset
|
268 |
end; |