author | paulson |
Fri, 16 Sep 2005 11:39:09 +0200 | |
changeset 17435 | 0eed5a1c00c1 |
parent 17422 | 3b237822985d |
child 17484 | f6a225f97f0a |
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 |
(* Parsing functions *) |
7 |
||
8 |
(* Auxiliary functions *) |
|
9 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
10 |
structure Recon_Parse = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
11 |
struct |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
12 |
|
16804 | 13 |
open ReconPrelim ReconTranslateProof; |
15642 | 14 |
|
15 |
exception NOPARSE_WORD |
|
16 |
exception NOPARSE_NUM |
|
17 |
fun to_upper s = String.translate (Char.toString o Char.toUpper) s; |
|
18 |
||
19 |
fun string2int s = |
|
16804 | 20 |
(case Int.fromString s of SOME i => i |
21 |
| NONE => raise ASSERTION "string -> int failed"); |
|
22 |
||
15642 | 23 |
|
24 |
(* Parser combinators *) |
|
25 |
||
26 |
exception Noparse; |
|
27 |
||
15688 | 28 |
fun (parser1 ++ parser2) input = |
15642 | 29 |
let |
30 |
val (result1, rest1) = parser1 input |
|
31 |
val (result2, rest2) = parser2 rest1 |
|
32 |
in |
|
33 |
((result1, result2), rest2) |
|
34 |
end; |
|
35 |
||
36 |
fun many parser input = |
|
37 |
let (* Tree * token list*) |
|
38 |
val (result, next) = parser input |
|
39 |
val (results, rest) = many parser next |
|
40 |
in |
|
41 |
((result::results), rest) |
|
42 |
end |
|
43 |
handle Noparse => ([], input) |
|
44 |
| NOPARSE_WORD => ([], input) |
|
45 |
| NOPARSE_NUM => ([], input); |
|
46 |
||
47 |
||
48 |
||
15688 | 49 |
fun (parser >> treatment) input = |
15642 | 50 |
let |
51 |
val (result, rest) = parser input |
|
52 |
in |
|
53 |
(treatment result, rest) |
|
54 |
end; |
|
55 |
||
15688 | 56 |
fun (parser1 || parser2) input = parser1 input |
15642 | 57 |
handle Noparse => parser2 input; |
58 |
||
59 |
infixr 8 ++; infixr 7 >>; infixr 6 ||; |
|
60 |
||
61 |
fun some p [] = raise Noparse |
|
62 |
| some p (h::t) = if p h then (h, t) else raise Noparse; |
|
63 |
||
64 |
fun a tok = some (fn item => item = tok); |
|
65 |
||
66 |
fun finished input = if input = [] then (0, input) else raise Noparse; |
|
67 |
||
68 |
||
69 |
||
70 |
||
71 |
||
72 |
(* Parsing the output from gandalf *) |
|
73 |
datatype token = Word of string |
|
74 |
| Number of int |
|
75 |
| Other of string |
|
76 |
||
77 |
||
78 |
exception NOCUT |
|
79 |
fun is_prefix [] l = true |
|
80 |
| is_prefix (h::t) [] = false |
|
81 |
| is_prefix (h::t) (h'::t') = (h = h') andalso is_prefix t t' |
|
82 |
fun remove_prefix [] l = l |
|
83 |
| remove_prefix (h::t) [] = raise (ASSERTION "can't remove prefix") |
|
84 |
| remove_prefix (h::t) (h'::t') = remove_prefix t t' |
|
85 |
fun ccut t [] = raise NOCUT |
|
86 |
| ccut t s = |
|
87 |
if is_prefix t s then ([], remove_prefix t s) else |
|
88 |
let val (a, b) = ccut t (tl s) in ((hd s)::a, b) end |
|
89 |
fun cut t s = |
|
90 |
let |
|
91 |
val t' = explode t |
|
92 |
val s' = explode s |
|
93 |
val (a, b) = ccut t' s' |
|
94 |
in |
|
95 |
(implode a, implode b) |
|
96 |
end |
|
97 |
||
98 |
fun cut_exists t s |
|
99 |
= let val (a, b) = cut t s in true end handle NOCUT => false |
|
100 |
||
101 |
fun cut_before t s = let val (a, b) = cut t s in (a, t ^ b) end |
|
102 |
fun cut_after t s = let val (a, b) = cut t s in (a ^ t, b) end |
|
103 |
||
104 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
105 |
fun kill_lines 0 = Library.I |
15642 | 106 |
| kill_lines n = kill_lines (n - 1) o snd o cut_after "\n"; |
107 |
||
108 |
(*fun extract_proof s |
|
109 |
= if cut_exists "EMPTY CLAUSE DERIVED" s then |
|
110 |
(kill_lines 6 |
|
111 |
o snd o cut_after "EMPTY CLAUSE DERIVED" |
|
112 |
o fst o cut_after "contradiction.\n") s |
|
113 |
else |
|
114 |
raise (GandalfError "Couldn't find a proof.") |
|
115 |
*) |
|
116 |
||
17315
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
117 |
val start_E = "# Proof object starts here." |
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
118 |
val end_E = "# Proof object ends here." |
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
119 |
val start_V6 = "%================== Proof: ======================" |
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
120 |
val end_V6 = "%============== End of proof. ==================" |
17422 | 121 |
val start_V8 = "=========== Refutation ==========" |
122 |
val end_V8 = "======= End of refutation =======" |
|
17315
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
123 |
|
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
124 |
|
17306 | 125 |
(*Identifies the start/end lines of an ATP's output*) |
126 |
fun extract_proof s = |
|
127 |
if cut_exists "Here is a proof with" s then |
|
128 |
(kill_lines 0 |
|
129 |
o snd o cut_after ":" |
|
130 |
o snd o cut_after "Here is a proof with" |
|
131 |
o fst o cut_after " || -> .") s |
|
17435 | 132 |
else if cut_exists start_V8 s then |
133 |
(kill_lines 0 (*Vampire 8.0*) |
|
134 |
o snd o cut_after start_V8 |
|
135 |
o fst o cut_before end_V8) s |
|
17315
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
136 |
else if cut_exists end_E s then |
17306 | 137 |
(kill_lines 0 (*eproof*) |
17315
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
138 |
o snd o cut_after start_E |
5bf0e0aacc24
consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents:
17312
diff
changeset
|
139 |
o fst o cut_before end_E) s |
17306 | 140 |
else "??extract_proof failed" (*Couldn't find a proof*) |
16478 | 141 |
|
15642 | 142 |
fun several p = many (some p) |
16840 | 143 |
fun collect (h, t) = h ^ (fold_rev (fn s1 => fn s2 => s1 ^ s2) t "") |
15642 | 144 |
|
145 |
fun lower_letter s = ("a" <= s) andalso (s <= "z") |
|
146 |
fun upper_letter s = ("A" <= s) andalso (s <= "Z") |
|
147 |
fun digit s = ("0" <= s) andalso (s <= "9") |
|
148 |
fun letter s = lower_letter s orelse upper_letter s |
|
149 |
fun alpha s = letter s orelse (s = "_") |
|
150 |
fun alphanum s = alpha s orelse digit s |
|
151 |
fun space s = (s = " ") orelse (s = "\n") orelse (s = "\t") |
|
152 |
(* FIX this is stopping it picking up numbers *) |
|
153 |
val word = (some alpha ++ several alphanum) >> (Word o collect) |
|
154 |
val number = |
|
155 |
(some digit ++ several digit) >> (Number o string2int o collect) |
|
156 |
val other = some (K true) >> Other |
|
157 |
||
158 |
val token = (word || number || other) ++ several space >> fst |
|
159 |
val tokens = (several space ++ many token) >> snd |
|
160 |
val alltokens = (tokens ++ finished) >> fst |
|
161 |
||
162 |
(* val lex = fst ( alltokens ( (map str) explode))*) |
|
163 |
fun lex s = alltokens (explode s) |
|
164 |
||
16478 | 165 |
|
166 |
||
17312 | 167 |
(*String contains multiple lines, terminated with newline characters. |
168 |
A list consisting of the first number in each line is returned. *) |
|
169 |
fun get_linenums proofstr = |
|
170 |
let val numerics = String.tokens (not o Char.isDigit) |
|
171 |
fun firstno [] = NONE |
|
172 |
| firstno (x::xs) = Int.fromString x |
|
173 |
val lines = String.tokens (fn c => c = #"\n") proofstr |
|
174 |
in List.mapPartial (firstno o numerics) lines end |
|
16478 | 175 |
|
16520 | 176 |
|
16478 | 177 |
(************************************************************) |
178 |
||
179 |
(**************************************************) |
|
180 |
(* Code to parse SPASS proofs *) |
|
181 |
(**************************************************) |
|
182 |
||
15642 | 183 |
datatype Tree = Leaf of string |
184 |
| Branch of Tree * Tree |
|
185 |
||
186 |
||
187 |
fun number ((Number n)::rest) = (n, rest) |
|
188 |
| number _ = raise NOPARSE_NUM |
|
189 |
fun word ((Word w)::rest) = (w, rest) |
|
190 |
| word _ = raise NOPARSE_WORD |
|
191 |
||
192 |
fun other_char ( (Other p)::rest) = (p, rest) |
|
193 |
| other_char _ =raise NOPARSE_WORD |
|
194 |
||
195 |
val number_list = |
|
196 |
(number ++ many number) |
|
197 |
>> (fn (a, b) => (a::b)) |
|
198 |
||
199 |
val term_num = |
|
200 |
(number ++ (a (Other ".")) ++ number) >> (fn (a, (_, c)) => (a, c)) |
|
201 |
||
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
202 |
|
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
203 |
val term_num_list = (term_num ++ many (a (Other ",") ++ term_num >> snd) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
204 |
>> (fn (a, b) => (a::b))) |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
205 |
|
15642 | 206 |
val axiom = (a (Word "Inp")) |
207 |
>> (fn (_) => Axiom) |
|
208 |
||
209 |
||
210 |
val binary = (a (Word "Res")) ++ (a (Other ":")) |
|
211 |
++ term_num ++ (a (Other ",")) |
|
212 |
++ term_num |
|
213 |
>> (fn (_, (_, (c, (_, e)))) => Binary (c, e)) |
|
214 |
||
215 |
||
216 |
||
217 |
val factor = (a (Word "Fac")) ++ (a (Other ":")) |
|
218 |
++ term_num ++ (a (Other ",")) |
|
219 |
++ term_num |
|
220 |
>> (fn (_, (_, (c, (_, e)))) => Factor ((fst c), (snd c),(snd e))) |
|
221 |
||
222 |
val para = (a (Word "SPm")) ++ (a (Other ":")) |
|
223 |
++ term_num ++ (a (Other ",")) |
|
224 |
++ term_num |
|
225 |
>> (fn (_, (_, (c, (_, e)))) => Para (c, e)) |
|
226 |
||
16357 | 227 |
val super_l = (a (Word "SpL")) ++ (a (Other ":")) |
228 |
++ term_num ++ (a (Other ",")) |
|
229 |
++ term_num |
|
230 |
>> (fn (_, (_, (c, (_, e)))) => Super_l (c, e)) |
|
231 |
||
232 |
||
233 |
val super_r = (a (Word "SpR")) ++ (a (Other ":")) |
|
234 |
++ term_num ++ (a (Other ",")) |
|
235 |
++ term_num |
|
236 |
>> (fn (_, (_, (c, (_, e)))) => Super_r (c, e)) |
|
237 |
||
238 |
||
239 |
val aed = (a (Word "AED")) ++ (a (Other ":")) ++ term_num |
|
240 |
>> (fn (_, (_, c)) => Obvious ((fst c),(snd c))) |
|
241 |
||
15642 | 242 |
val rewrite = (a (Word "Rew")) ++ (a (Other ":")) |
16548
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
243 |
++ term_num_list |
aa36ae6b955e
Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents:
16520
diff
changeset
|
244 |
>> (fn (_, (_, (c))) => Rewrite (c)) |
15642 | 245 |
|
246 |
||
247 |
val mrr = (a (Word "MRR")) ++ (a (Other ":")) |
|
248 |
++ term_num ++ (a (Other ",")) |
|
249 |
++ term_num |
|
250 |
>> (fn (_, (_, (c, (_, e)))) => MRR (c, e)) |
|
251 |
||
16357 | 252 |
val ssi = (a (Word "SSi")) ++ (a (Other ":")) |
253 |
++ term_num ++ (a (Other ",")) |
|
254 |
++ term_num |
|
255 |
>> (fn (_, (_, (c, (_, e)))) => SortSimp (c, e)) |
|
256 |
||
257 |
val unc = (a (Word "UnC")) ++ (a (Other ":")) |
|
258 |
++ term_num ++ (a (Other ",")) |
|
259 |
++ term_num |
|
260 |
>> (fn (_, (_, (c, (_, e)))) => UnitConf (c, e)) |
|
261 |
||
262 |
||
15642 | 263 |
|
264 |
val obv = (a (Word "Obv")) ++ (a (Other ":")) ++ term_num |
|
265 |
>> (fn (_, (_, c)) => Obvious ((fst c),(snd c))) |
|
16357 | 266 |
|
267 |
val eqres = (a (Word "EqR")) ++ (a (Other ":")) ++ term_num |
|
268 |
>> (fn (_, (_, c)) => EqualRes ((fst c),(snd c))) |
|
269 |
||
270 |
val con = (a (Word "Con")) ++ (a (Other ":")) ++ term_num |
|
271 |
>> (fn (_, (_, c)) => Condense ((fst c),(snd c))) |
|
272 |
||
15642 | 273 |
(* |
274 |
val hyper = a (Word "hyper") |
|
275 |
++ many ((a (Other ",") ++ number) >> snd) |
|
276 |
>> (Hyper o snd) |
|
277 |
*) |
|
278 |
(* val method = axiom ||binary || factor || para || hyper*) |
|
279 |
||
16357 | 280 |
val method = axiom || binary || factor || para ||super_l || super_r || rewrite || mrr || obv || aed || ssi || unc|| con |
281 |
||
15642 | 282 |
val binary_s = a (Word "binary_s") ++ a (Other ",") ++ term_num |
283 |
>> (fn (_, (_, a)) => Binary_s a) |
|
284 |
val factor_s = a (Word "factor_s") |
|
285 |
>> (fn _ => Factor_s ()) |
|
286 |
val demod_s = a (Word "demod") |
|
287 |
++ (many ((a (Other ",") ++ term_num) >> snd)) |
|
288 |
>> (fn (_, a) => Demod_s a) |
|
289 |
||
290 |
val hyper_s = a (Word "hyper_s") |
|
291 |
++ many ((a (Other ",") ++ number) >> snd) |
|
292 |
>> (Hyper_s o snd) |
|
293 |
val simp_method = binary_s || factor_s || demod_s || hyper_s |
|
294 |
val simp = a (Other ",") ++ simp_method >> snd |
|
295 |
val simps = many simp |
|
296 |
||
297 |
||
298 |
val justification = |
|
299 |
a (Other "[") ++number ++ a (Other ":") ++ method ++ a (Other "]") |
|
300 |
>> (fn (_,(_, (_,(b, _)))) => b) |
|
301 |
||
302 |
||
303 |
exception NOTERM |
|
304 |
||
305 |
(* FIX - should change the stars and pluses to many rather than explicit patterns *) |
|
306 |
||
16953 | 307 |
fun trim_prefix a b = |
308 |
let val n = String.size a |
|
309 |
in String.substring (b, n, (size b) - n) end; |
|
310 |
||
311 |
||
15642 | 312 |
(* FIX - add the other things later *) |
16953 | 313 |
fun remove_typeinfo x = |
314 |
if String.isPrefix ResClause.fixed_var_prefix x |
|
315 |
then trim_prefix ResClause.fixed_var_prefix x |
|
316 |
else if String.isPrefix ResClause.schematic_var_prefix x |
|
317 |
then trim_prefix ResClause.schematic_var_prefix x |
|
318 |
else if String.isPrefix ResClause.const_prefix x |
|
319 |
then trim_prefix ResClause.const_prefix x |
|
320 |
else if String.isPrefix ResClause.tfree_prefix x |
|
321 |
then "" |
|
322 |
else if String.isPrefix ResClause.tvar_prefix x |
|
323 |
then "" |
|
324 |
else if String.isPrefix ResClause.tconst_prefix x |
|
325 |
then "" |
|
326 |
else x; |
|
15642 | 327 |
|
328 |
fun term input = ( ntermlist ++ a (Other "-") ++ a (Other ">") ++ ptermlist >>(fn (a,(_,(_,b))) => (a@b)) |
|
329 |
) input |
|
330 |
||
331 |
(* pterms are terms from the rhs of the -> in the spass proof. *) |
|
332 |
(* they should have a "~" in front of them so that they match with *) |
|
333 |
(* positive terms in the meta-clause *) |
|
334 |
(* nterm are terms from the lhs of the spass proof, and shouldn't *) |
|
335 |
(* "~"s added word ++ a (Other "(") ++ arglist ++ a (Other ")") >> (fn (a,(_,(b,_ ))) => (a^" "^b)) *) |
|
336 |
||
337 |
and pterm input = ( |
|
338 |
peqterm >> (fn (a) => a) |
|
339 |
||
340 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ 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 "*") ++ a (Other "*") |
|
347 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
348 |
||
349 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") |
|
350 |
>> (fn (a, (_,(b, (_,_)))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
351 |
||
352 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") |
|
353 |
>> (fn ( a, (_,(b,_ ))) => ("~"^" "^(remove_typeinfo a)^" "^b)) |
|
354 |
||
16357 | 355 |
|| word ++ a (Other "*") >> (fn (w,b) => "~"^" "^(remove_typeinfo w)) |
356 |
||
357 |
|| word >> (fn w => "~"^" "^(remove_typeinfo w))) input |
|
15642 | 358 |
|
359 |
and nterm input = |
|
360 |
||
361 |
( |
|
362 |
neqterm >> (fn (a) => a) |
|
363 |
||
364 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ 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 "*") ++ a (Other "*") |
|
371 |
>> (fn ( a, (_,(b, (_,(_,_))))) => ((remove_typeinfo a)^" "^b)) |
|
372 |
||
373 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") ++ a (Other "*") |
|
374 |
>> (fn ( a, (_,(b, (_,_)))) => ((remove_typeinfo a)^" "^b)) |
|
375 |
||
376 |
|| word ++ a (Other "(") ++ arglist ++ a (Other ")") |
|
377 |
>> (fn (a, (_,(b,_ ))) => ((remove_typeinfo a)^" "^b)) |
|
378 |
||
16357 | 379 |
|| word ++ a (Other "*") >> (fn (w,b) => (remove_typeinfo w)) |
380 |
|| word >> (fn w => (remove_typeinfo w)) |
|
381 |
) input |
|
15642 | 382 |
|
383 |
||
384 |
and peqterm input =( |
|
385 |
||
386 |
a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
387 |
++ a (Other "*") ++ a (Other "*") ++ a (Other "+") |
|
388 |
>> (fn (_,(_,(a,(_,(b,(_,(_,(_,_)))))))) => (a^" ~= "^b)) |
|
389 |
||
390 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
391 |
++ a (Other "*") ++ a (Other "+") |
|
392 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" ~= "^b)) |
|
393 |
||
394 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
395 |
++ a (Other "*") ++ a (Other "*") |
|
396 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" ~= "^b)) |
|
397 |
||
398 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
399 |
++ a (Other "*") |
|
400 |
>> (fn (_,(_,(a,(_,(b,(_,_)))))) => (a^" ~= "^b)) |
|
401 |
||
402 |
||
403 |
||a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
404 |
>> (fn (_,(_,(a,(_,(b,_))))) => (a^" ~= "^b))) input |
|
405 |
||
406 |
||
407 |
||
408 |
and neqterm input =( |
|
409 |
||
410 |
a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
411 |
++ a (Other "*") ++ a (Other "*") ++ a (Other "+") |
|
412 |
>> (fn (_,(_,(a,(_,(b,(_,(_,(_,_)))))))) => (a^" = "^b)) |
|
413 |
||
414 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
415 |
++ a (Other "*") ++ a (Other "+") |
|
416 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" = "^b)) |
|
417 |
||
418 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
419 |
++ a (Other "*") ++ a (Other "*") |
|
420 |
>> (fn (_,(_,(a,(_,(b,(_,(_,_))))))) => (a^" = "^b)) |
|
421 |
||
422 |
|| a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
423 |
++ a (Other "*") |
|
424 |
>> (fn (_,(_,(a,(_,(b,(_,_)))))) => (a^" = "^b)) |
|
425 |
||
426 |
||
427 |
||a (Word "equal") ++ a (Other "(") ++ nterm ++ a (Other ",") ++ nterm ++ a (Other ")") |
|
428 |
>> (fn (_,(_,(a,(_,(b,_))))) => (a^" = "^b))) input |
|
429 |
||
430 |
||
431 |
||
432 |
and ptermlist input = (many pterm |
|
433 |
>> (fn (a) => (a))) input |
|
434 |
||
435 |
and ntermlist input = (many nterm |
|
436 |
>> (fn (a) => (a))) input |
|
437 |
||
438 |
(*and arglist input = ( nterm >> (fn (a) => (a)) |
|
439 |
|| nterm ++ many (a (Other ",") ++ nterm >> snd) |
|
17306 | 440 |
>> (fn (a, b) => (a^" "^(space_implode " " b)))) input*) |
15642 | 441 |
|
442 |
and arglist input = ( nterm ++ many (a (Other ",") ++ nterm >> snd) |
|
17306 | 443 |
>> (fn (a, b) => (a^" "^(space_implode " " b))) |
15642 | 444 |
|| nterm >> (fn (a) => (a)))input |
445 |
||
446 |
val clause = term |
|
447 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
448 |
(* 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
|
449 |
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
|
450 |
a (Other "|") ++ clause ++ a (Other ".") |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15789
diff
changeset
|
451 |
>> (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
|
452 |
|
15642 | 453 |
val lines = many line |
454 |
val alllines = (lines ++ finished) >> fst |
|
455 |
||
456 |
val parse = fst o alllines |
|
457 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15642
diff
changeset
|
458 |
end; |