author | quigley |
Fri, 10 Jun 2005 16:15:36 +0200 | |
changeset 16357 | f1275d2a1dee |
parent 16061 | 8a139c1557bf |
child 16418 | 5d0d24bd2c96 |
permissions | -rw-r--r-- |
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15688
diff
changeset
|
1 |
(* ID: $Id$ |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15688
diff
changeset
|
2 |
Author: Claire Quigley |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15688
diff
changeset
|
3 |
Copyright 2004 University of Cambridge |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15688
diff
changeset
|
4 |
*) |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15688
diff
changeset
|
5 |
|
15642 | 6 |
(*use "Translate_Proof";*) |
7 |
(* Parsing functions *) |
|
8 |
||
9 |
(* Auxiliary functions *) |
|
10 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
11 |
structure Recon_Parse = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
12 |
struct |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
13 |
|
15642 | 14 |
exception ASSERTION of string; |
15 |
||
16 |
exception NOPARSE_WORD |
|
17 |
exception NOPARSE_NUM |
|
18 |
fun to_upper s = String.translate (Char.toString o Char.toUpper) s; |
|
19 |
||
20 |
fun string2int s = |
|
21 |
let |
|
22 |
val io = Int.fromString s |
|
23 |
in |
|
24 |
case io of |
|
25 |
(SOME i) => i |
|
26 |
| _ => raise ASSERTION "string -> int failed" |
|
27 |
end |
|
28 |
||
29 |
(* Parser combinators *) |
|
30 |
||
31 |
exception Noparse; |
|
32 |
exception SPASSError of string; |
|
33 |
||
15688 | 34 |
fun (parser1 ++ parser2) input = |
15642 | 35 |
let |
36 |
val (result1, rest1) = parser1 input |
|
37 |
val (result2, rest2) = parser2 rest1 |
|
38 |
in |
|
39 |
((result1, result2), rest2) |
|
40 |
end; |
|
41 |
||
42 |
fun many parser input = |
|
43 |
let (* Tree * token list*) |
|
44 |
val (result, next) = parser input |
|
45 |
val (results, rest) = many parser next |
|
46 |
in |
|
47 |
((result::results), rest) |
|
48 |
end |
|
49 |
handle Noparse => ([], input) |
|
50 |
| NOPARSE_WORD => ([], input) |
|
51 |
| NOPARSE_NUM => ([], input); |
|
52 |
||
53 |
||
54 |
||
15688 | 55 |
fun (parser >> treatment) input = |
15642 | 56 |
let |
57 |
val (result, rest) = parser input |
|
58 |
in |
|
59 |
(treatment result, rest) |
|
60 |
end; |
|
61 |
||
15688 | 62 |
fun (parser1 || parser2) input = parser1 input |
15642 | 63 |
handle Noparse => parser2 input; |
64 |
||
65 |
infixr 8 ++; infixr 7 >>; infixr 6 ||; |
|
66 |
||
67 |
fun some p [] = raise Noparse |
|
68 |
| some p (h::t) = if p h then (h, t) else raise Noparse; |
|
69 |
||
70 |
fun a tok = some (fn item => item = tok); |
|
71 |
||
72 |
fun finished input = if input = [] then (0, input) else raise Noparse; |
|
73 |
||
74 |
||
75 |
||
76 |
||
77 |
||
78 |
(* Parsing the output from gandalf *) |
|
79 |
datatype token = Word of string |
|
80 |
| Number of int |
|
81 |
| Other of string |
|
82 |
||
83 |
||
84 |
exception NOCUT |
|
85 |
fun is_prefix [] l = true |
|
86 |
| is_prefix (h::t) [] = false |
|
87 |
| is_prefix (h::t) (h'::t') = (h = h') andalso is_prefix t t' |
|
88 |
fun remove_prefix [] l = l |
|
89 |
| remove_prefix (h::t) [] = raise (ASSERTION "can't remove prefix") |
|
90 |
| remove_prefix (h::t) (h'::t') = remove_prefix t t' |
|
91 |
fun ccut t [] = raise NOCUT |
|
92 |
| ccut t s = |
|
93 |
if is_prefix t s then ([], remove_prefix t s) else |
|
94 |
let val (a, b) = ccut t (tl s) in ((hd s)::a, b) end |
|
95 |
fun cut t s = |
|
96 |
let |
|
97 |
val t' = explode t |
|
98 |
val s' = explode s |
|
99 |
val (a, b) = ccut t' s' |
|
100 |
in |
|
101 |
(implode a, implode b) |
|
102 |
end |
|
103 |
||
104 |
fun cut_exists t s |
|
105 |
= let val (a, b) = cut t s in true end handle NOCUT => false |
|
106 |
||
107 |
fun cut_before t s = let val (a, b) = cut t s in (a, t ^ b) end |
|
108 |
fun cut_after t s = let val (a, b) = cut t s in (a ^ t, b) end |
|
109 |
||
110 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
111 |
fun kill_lines 0 = Library.I |
15642 | 112 |
| kill_lines n = kill_lines (n - 1) o snd o cut_after "\n"; |
113 |
||
114 |
(*fun extract_proof s |
|
115 |
= if cut_exists "EMPTY CLAUSE DERIVED" s then |
|
116 |
(kill_lines 6 |
|
117 |
o snd o cut_after "EMPTY CLAUSE DERIVED" |
|
118 |
o fst o cut_after "contradiction.\n") s |
|
119 |
else |
|
120 |
raise (GandalfError "Couldn't find a proof.") |
|
121 |
*) |
|
122 |
||
123 |
val proofstring = |
|
124 |
"0:00:00.00 for the reduction.\ |
|
125 |
\\ |
|
126 |
\Here is a proof with depth 3, length 7 :\ |
|
127 |
\1[0:Inp] || -> P(xa)*.\ |
|
128 |
\2[0:Inp] || -> Q(xb)*.\ |
|
129 |
\3[0:Inp] || R(U)* -> .\ |
|
130 |
\4[0:Inp] || Q(U) P(V) -> R(x(V,U))*.\ |
|
131 |
\9[0:Res:4.2,3.0] || Q(U)*+ P(V)* -> .\ |
|
132 |
\11[0:Res:2.0,9.0] || P(U)* -> .\ |
|
133 |
\12[0:Res:1.0,11.0] || -> .\ |
|
134 |
\Formulae used in the proof :\ |
|
135 |
\\ |
|
136 |
\--------------------------SPASS-STOP------------------------------" |
|
137 |
||
138 |
||
139 |
fun extract_proof s |
|
140 |
= if cut_exists "Here is a proof with" s then |
|
141 |
(kill_lines 0 |
|
142 |
o snd o cut_after ":" |
|
143 |
o snd o cut_after "Here is a proof with" |
|
144 |
o fst o cut_after " || -> .") s |
|
145 |
else |
|
146 |
raise SPASSError "Couldn't find a proof." |
|
147 |
||
148 |
||
149 |
||
150 |
fun several p = many (some p) |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
151 |
fun collect (h, t) = h ^ (Utils.itlist (fn s1 => fn s2 => s1 ^ s2) t "") |
15642 | 152 |
|
153 |
fun lower_letter s = ("a" <= s) andalso (s <= "z") |
|
154 |
fun upper_letter s = ("A" <= s) andalso (s <= "Z") |
|
155 |
fun digit s = ("0" <= s) andalso (s <= "9") |
|
156 |
fun letter s = lower_letter s orelse upper_letter s |
|
157 |
fun alpha s = letter s orelse (s = "_") |
|
158 |
fun alphanum s = alpha s orelse digit s |
|
159 |
fun space s = (s = " ") orelse (s = "\n") orelse (s = "\t") |
|
160 |
(* FIX this is stopping it picking up numbers *) |
|
161 |
val word = (some alpha ++ several alphanum) >> (Word o collect) |
|
162 |
val number = |
|
163 |
(some digit ++ several digit) >> (Number o string2int o collect) |
|
164 |
val other = some (K true) >> Other |
|
165 |
||
166 |
val token = (word || number || other) ++ several space >> fst |
|
167 |
val tokens = (several space ++ many token) >> snd |
|
168 |
val alltokens = (tokens ++ finished) >> fst |
|
169 |
||
170 |
(* val lex = fst ( alltokens ( (map str) explode))*) |
|
171 |
fun lex s = alltokens (explode s) |
|
172 |
||
173 |
datatype Tree = Leaf of string |
|
174 |
| Branch of Tree * Tree |
|
175 |
||
176 |
||
177 |
||
178 |
||
179 |
fun number ((Number n)::rest) = (n, rest) |
|
180 |
| number _ = raise NOPARSE_NUM |
|
181 |
fun word ((Word w)::rest) = (w, rest) |
|
182 |
| word _ = raise NOPARSE_WORD |
|
183 |
||
184 |
fun other_char ( (Other p)::rest) = (p, rest) |
|
185 |
| other_char _ =raise NOPARSE_WORD |
|
186 |
||
187 |
val number_list = |
|
188 |
(number ++ many number) |
|
189 |
>> (fn (a, b) => (a::b)) |
|
190 |
||
191 |
val term_num = |
|
192 |
(number ++ (a (Other ".")) ++ number) >> (fn (a, (_, c)) => (a, c)) |
|
193 |
||
194 |
val axiom = (a (Word "Inp")) |
|
195 |
>> (fn (_) => Axiom) |
|
196 |
||
197 |
||
198 |
val binary = (a (Word "Res")) ++ (a (Other ":")) |
|
199 |
++ term_num ++ (a (Other ",")) |
|
200 |
++ term_num |
|
201 |
>> (fn (_, (_, (c, (_, e)))) => Binary (c, e)) |
|
202 |
||
203 |
||
204 |
||
205 |
val factor = (a (Word "Fac")) ++ (a (Other ":")) |
|
206 |
++ term_num ++ (a (Other ",")) |
|
207 |
++ term_num |
|
208 |
>> (fn (_, (_, (c, (_, e)))) => Factor ((fst c), (snd c),(snd e))) |
|
209 |
||
210 |
val para = (a (Word "SPm")) ++ (a (Other ":")) |
|
211 |
++ term_num ++ (a (Other ",")) |
|
212 |
++ term_num |
|
213 |
>> (fn (_, (_, (c, (_, e)))) => Para (c, e)) |
|
214 |
||
16357 | 215 |
val super_l = (a (Word "SpL")) ++ (a (Other ":")) |
216 |
++ term_num ++ (a (Other ",")) |
|
217 |
++ term_num |
|
218 |
>> (fn (_, (_, (c, (_, e)))) => Super_l (c, e)) |
|
219 |
||
220 |
||
221 |
val super_r = (a (Word "SpR")) ++ (a (Other ":")) |
|
222 |
++ term_num ++ (a (Other ",")) |
|
223 |
++ term_num |
|
224 |
>> (fn (_, (_, (c, (_, e)))) => Super_r (c, e)) |
|
225 |
||
226 |
||
227 |
val aed = (a (Word "AED")) ++ (a (Other ":")) ++ term_num |
|
228 |
>> (fn (_, (_, c)) => Obvious ((fst c),(snd c))) |
|
229 |
||
15642 | 230 |
val rewrite = (a (Word "Rew")) ++ (a (Other ":")) |
231 |
++ term_num ++ (a (Other ",")) |
|
232 |
++ term_num |
|
233 |
>> (fn (_, (_, (c, (_, e)))) => Rewrite (c, e)) |
|
234 |
||
235 |
||
236 |
val mrr = (a (Word "MRR")) ++ (a (Other ":")) |
|
237 |
++ term_num ++ (a (Other ",")) |
|
238 |
++ term_num |
|
239 |
>> (fn (_, (_, (c, (_, e)))) => MRR (c, e)) |
|
240 |
||
16357 | 241 |
val ssi = (a (Word "SSi")) ++ (a (Other ":")) |
242 |
++ term_num ++ (a (Other ",")) |
|
243 |
++ term_num |
|
244 |
>> (fn (_, (_, (c, (_, e)))) => SortSimp (c, e)) |
|
245 |
||
246 |
val unc = (a (Word "UnC")) ++ (a (Other ":")) |
|
247 |
++ term_num ++ (a (Other ",")) |
|
248 |
++ term_num |
|
249 |
>> (fn (_, (_, (c, (_, e)))) => UnitConf (c, e)) |
|
250 |
||
251 |
||
15642 | 252 |
|
253 |
val obv = (a (Word "Obv")) ++ (a (Other ":")) ++ term_num |
|
254 |
>> (fn (_, (_, c)) => Obvious ((fst c),(snd c))) |
|
16357 | 255 |
|
256 |
val eqres = (a (Word "EqR")) ++ (a (Other ":")) ++ term_num |
|
257 |
>> (fn (_, (_, c)) => EqualRes ((fst c),(snd c))) |
|
258 |
||
259 |
val con = (a (Word "Con")) ++ (a (Other ":")) ++ term_num |
|
260 |
>> (fn (_, (_, c)) => Condense ((fst c),(snd c))) |
|
261 |
||
15642 | 262 |
(* |
263 |
val hyper = a (Word "hyper") |
|
264 |
++ many ((a (Other ",") ++ number) >> snd) |
|
265 |
>> (Hyper o snd) |
|
266 |
*) |
|
267 |
(* val method = axiom ||binary || factor || para || hyper*) |
|
268 |
||
16357 | 269 |
val method = axiom || binary || factor || para ||super_l || super_r || rewrite || mrr || obv || aed || ssi || unc|| con |
270 |
||
15642 | 271 |
val binary_s = a (Word "binary_s") ++ a (Other ",") ++ term_num |
272 |
>> (fn (_, (_, a)) => Binary_s a) |
|
273 |
val factor_s = a (Word "factor_s") |
|
274 |
>> (fn _ => Factor_s ()) |
|
275 |
val demod_s = a (Word "demod") |
|
276 |
++ (many ((a (Other ",") ++ term_num) >> snd)) |
|
277 |
>> (fn (_, a) => Demod_s a) |
|
278 |
||
279 |
val hyper_s = a (Word "hyper_s") |
|
280 |
++ many ((a (Other ",") ++ number) >> snd) |
|
281 |
>> (Hyper_s o snd) |
|
282 |
val simp_method = binary_s || factor_s || demod_s || hyper_s |
|
283 |
val simp = a (Other ",") ++ simp_method >> snd |
|
284 |
val simps = many simp |
|
285 |
||
286 |
||
287 |
val justification = |
|
288 |
a (Other "[") ++number ++ a (Other ":") ++ method ++ a (Other "]") |
|
289 |
>> (fn (_,(_, (_,(b, _)))) => b) |
|
290 |
||
291 |
||
292 |
exception NOTERM |
|
293 |
||
294 |
||
295 |
fun implode_with_space [] = implode [] |
|
296 |
| implode_with_space [x] = implode [x] |
|
297 |
| implode_with_space (x::[y]) = x^" "^y |
|
298 |
| implode_with_space (x::xs) = (x^" "^(implode_with_space xs)) |
|
299 |
||
300 |
(* FIX - should change the stars and pluses to many rather than explicit patterns *) |
|
301 |
||
302 |
(* FIX - add the other things later *) |
|
303 |
fun remove_typeinfo x = if (String.isPrefix "v_" x ) |
|
304 |
then |
|
305 |
(String.substring (x,2, ((size x) - 2))) |
|
306 |
else if (String.isPrefix "V_" x ) |
|
307 |
then |
|
308 |
(String.substring (x,2, ((size x) - 2))) |
|
309 |
else if (String.isPrefix "typ_" x ) |
|
310 |
then |
|
311 |
"" |
|
312 |
else if (String.isPrefix "Typ_" x ) |
|
313 |
then |
|
314 |
"" |
|
315 |
else if (String.isPrefix "tconst_" x ) |
|
316 |
then |
|
317 |
"" |
|
318 |
else if (String.isPrefix "const_" x ) |
|
319 |
then |
|
320 |
(String.substring (x,6, ((size x) - 6))) |
|
321 |
else |
|
322 |
x |
|
323 |
||
324 |
||
325 |
fun term input = ( ntermlist ++ a (Other "-") ++ a (Other ">") ++ ptermlist >>(fn (a,(_,(_,b))) => (a@b)) |
|
326 |
) input |
|
327 |
||
328 |
(* pterms are terms from the rhs of the -> in the spass proof. *) |
|
329 |
(* they should have a "~" in front of them so that they match with *) |
|
330 |
(* positive terms in the meta-clause *) |
|
331 |
(* nterm are terms from the lhs of the spass proof, and shouldn't *) |
|
332 |
(* "~"s added word ++ a (Other "(") ++ arglist ++ a (Other ")") >> (fn (a,(_,(b,_ ))) => (a^" "^b)) *) |
|
333 |
||
334 |
and pterm input = ( |
|
335 |
peqterm >> (fn (a) => a) |
|
336 |
||
337 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*")++ a (Other "*") ++ a (Other "+") |
|
338 |
>> (fn (a, (_,(b, (_,(_,_))))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
339 |
||
340 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") ++ a (Other "+") |
|
341 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
342 |
||
343 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") ++ a (Other "*") |
|
344 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
345 |
||
346 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") |
|
347 |
>> (fn (a, (_,(b, (_,_)))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
348 |
||
349 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") |
|
350 |
>> (fn ( a, (_,(b,_ ))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
351 |
||
16357 | 352 |
|| word ++ a (Other "*") >> (fn (w,b) => "~"^" "^(remove_typeinfo w)) |
353 |
||
354 |
|| word >> (fn w => "~"^" "^(remove_typeinfo w))) input |
|
15642 | 355 |
|
356 |
and nterm input = |
|
357 |
||
358 |
( |
|
359 |
neqterm >> (fn (a) => a) |
|
360 |
||
361 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") ++ a (Other "*") ++ a (Other "+") |
|
362 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ((remove_typeinfo a)^" "^b)) |
|
363 |
||
364 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") ++ a (Other "+") |
|
365 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ((remove_typeinfo a)^" "^b)) |
|
366 |
||
367 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") ++ a (Other "*") |
|
368 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ((remove_typeinfo a)^" "^b)) |
|
369 |
||
370 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") |
|
371 |
>> (fn ( a, (_,(b, (_,_)))) => ((remove_typeinfo a)^" "^b)) |
|
372 |
||
373 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") |
|
374 |
>> (fn (a, (_,(b,_ ))) => ((remove_typeinfo a)^" "^b)) |
|
375 |
||
16357 | 376 |
|| word ++ a (Other "*") >> (fn (w,b) => (remove_typeinfo w)) |
377 |
|| word >> (fn w => (remove_typeinfo w)) |
|
378 |
) input |
|
15642 | 379 |
|
380 |
||
381 |
and peqterm input =( |
|
382 |
||
383 |
a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
384 |
++ a (Other "*") ++ a (Other "*") ++ a (Other "+") |
|
385 |
>> (fn (_,(_,(a,(_,(b,(_,(_,(_,_)))))))) => (a^" ~= "^b)) |
|
386 |
||
387 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
388 |
++ a (Other "*") ++ a (Other "+") |
|
389 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" ~= "^b)) |
|
390 |
||
391 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
392 |
++ a (Other "*") ++ a (Other "*") |
|
393 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" ~= "^b)) |
|
394 |
||
395 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
396 |
++ a (Other "*") |
|
397 |
>> (fn (_,(_,(a,(_,(b,(_,_)))))) => (a^" ~= "^b)) |
|
398 |
||
399 |
||
400 |
||a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
401 |
>> (fn (_,(_,(a,(_,(b,_))))) => (a^" ~= "^b))) input |
|
402 |
||
403 |
||
404 |
||
405 |
and neqterm input =( |
|
406 |
||
407 |
a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
408 |
++ a (Other "*") ++ a (Other "*") ++ a (Other "+") |
|
409 |
>> (fn (_,(_,(a,(_,(b,(_,(_,(_,_)))))))) => (a^" = "^b)) |
|
410 |
||
411 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
412 |
++ a (Other "*") ++ a (Other "+") |
|
413 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" = "^b)) |
|
414 |
||
415 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
416 |
++ a (Other "*") ++ a (Other "*") |
|
417 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" = "^b)) |
|
418 |
||
419 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
420 |
++ a (Other "*") |
|
421 |
>> (fn (_,(_,(a,(_,(b,(_,_)))))) => (a^" = "^b)) |
|
422 |
||
423 |
||
424 |
||a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
425 |
>> (fn (_,(_,(a,(_,(b,_))))) => (a^" = "^b))) input |
|
426 |
||
427 |
||
428 |
||
429 |
and ptermlist input = (many pterm |
|
430 |
>> (fn (a) => (a))) input |
|
431 |
||
432 |
and ntermlist input = (many nterm |
|
433 |
>> (fn (a) => (a))) input |
|
434 |
||
435 |
(*and arglist input = ( nterm >> (fn (a) => (a)) |
|
436 |
|| nterm ++ many (a (Other ",") ++ nterm >> snd) |
|
437 |
>> (fn (a, b) => (a^" "^(implode_with_space b)))) input*) |
|
438 |
||
439 |
and arglist input = ( nterm ++ many (a (Other ",") ++ nterm >> snd) |
|
440 |
>> (fn (a, b) => (a^" "^(implode_with_space b))) |
|
441 |
|| nterm >> (fn (a) => (a)))input |
|
442 |
||
443 |
val clause = term |
|
444 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
445 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
446 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
447 |
(*val line = number ++ justification ++ a (Other "|") ++ |
15642 | 448 |
a (Other "|") ++ clause ++ a (Other ".") |
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
449 |
>> (fn (a, (z, (_,( _, (c, _))))) => (a, z, c))*) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
450 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
451 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
452 |
(* not entirely sure nterm is right here, but I don't think you get negative things before the ||s *) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
453 |
val line = number ++ justification ++ many( nterm) ++ a (Other "|") ++ |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
454 |
a (Other "|") ++ clause ++ a (Other ".") |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
455 |
>> (fn (a, (z, (w, (_,( _, (c, _)))))) => (a, z,(w@ c))) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
456 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
457 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
458 |
|
15642 | 459 |
val lines = many line |
460 |
val alllines = (lines ++ finished) >> fst |
|
461 |
||
462 |
val parse = fst o alllines |
|
463 |
val s = proofstring; |
|
464 |
||
465 |
||
466 |
||
467 |
||
468 |
fun dropUntilNot ch [] = ( []) |
|
469 |
| dropUntilNot ch (x::xs) = if not(x = ch ) |
|
470 |
then |
|
471 |
(x::xs) |
|
472 |
else |
|
473 |
dropUntilNot ch xs |
|
474 |
||
475 |
||
476 |
fun remove_spaces str [] = str |
|
477 |
| remove_spaces str (x::[]) = if x = " " |
|
478 |
then |
|
479 |
str |
|
480 |
else |
|
481 |
(str^x) |
|
16061 | 482 |
| remove_spaces str (x::xs) = |
483 |
let val (first, rest) = ReconOrderClauses.takeUntil " " (x::xs) [] |
|
484 |
val (next) = dropUntilNot " " rest |
|
485 |
in |
|
486 |
if next = [] |
|
487 |
then |
|
488 |
(str^(implode first)) |
|
489 |
else remove_spaces (str^(implode first)^" ") next |
|
490 |
end |
|
15642 | 491 |
|
492 |
||
493 |
fun remove_space_strs clsstrs = map (remove_spaces "") (map explode clsstrs) |
|
494 |
||
495 |
||
496 |
fun all_spaces xs = List.filter (not_equal " " ) xs |
|
497 |
||
498 |
fun just_change_space [] = [] |
|
16061 | 499 |
| just_change_space ((clausenum, step, strs)::xs) = |
500 |
let val newstrs = remove_space_strs strs |
|
501 |
in |
|
502 |
if (all_spaces newstrs = [] ) (* all type_info *) |
|
503 |
then |
|
504 |
(clausenum, step, newstrs)::(just_change_space xs) |
|
505 |
else |
|
506 |
(clausenum, step, newstrs)::(just_change_space xs) |
|
507 |
end; |
|
15642 | 508 |
|
509 |
fun change_space [] = [] |
|
16061 | 510 |
| change_space ((clausenum, step, strs)::xs) = |
511 |
let val newstrs = remove_space_strs strs |
|
512 |
in |
|
513 |
if (all_spaces newstrs = [] ) (* all type_info *) |
|
514 |
then |
|
515 |
(clausenum, step, T_info, newstrs)::(change_space xs) |
|
516 |
else |
|
517 |
(clausenum, step, P_info, newstrs)::(change_space xs) |
|
518 |
end |
|
15642 | 519 |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
520 |
end; |