author | paulson |
Mon, 11 Apr 2005 16:25:31 +0200 | |
changeset 15697 | 681bcb7f0389 |
parent 15684 | 5ec4d21889d6 |
child 15736 | 1bb0399a9517 |
permissions | -rw-r--r-- |
15642 | 1 |
|
2 |
||
3 |
fun add_in_order (x:string) [] = [x] |
|
4 |
| add_in_order (x:string) ((y:string)::ys) = if (x < y) |
|
5 |
then |
|
6 |
(x::(y::ys)) |
|
7 |
else |
|
8 |
(y::(add_in_order x ys)) |
|
9 |
fun add_once x [] = [x] |
|
10 |
| add_once x (y::ys) = if (inlist x (y::ys)) then |
|
11 |
(y::ys) |
|
12 |
else |
|
13 |
add_in_order x (y::ys) |
|
14 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
15 |
fun thm_vars thm = map (fn ((name,ix),_) => name) (Drule.vars_of thm); |
15642 | 16 |
|
17 |
Goal "False ==> False"; |
|
18 |
by Auto_tac; |
|
19 |
qed "False_imp"; |
|
20 |
||
21 |
exception Reflex_equal; |
|
22 |
||
23 |
(********************************) |
|
24 |
(* Proofstep datatype *) |
|
25 |
(********************************) |
|
26 |
(* Assume rewrite steps have only two clauses in them just now, but lcl109-5 has Rew[5,3,5,3] *) |
|
27 |
||
28 |
datatype Side = Left |Right |
|
29 |
||
30 |
datatype Proofstep = ExtraAxiom |
|
31 |
|OrigAxiom |
|
32 |
| Axiom |
|
33 |
| Binary of (int * int) * (int * int) (* (clause1,lit1), (clause2, lit2) *) |
|
34 |
| MRR of (int * int) * (int * int) |
|
35 |
| Factor of (int * int * int) (* (clause,lit1, lit2) *) |
|
36 |
| Para of (int * int) * (int * int) |
|
37 |
| Rewrite of (int * int) * (int * int) |
|
38 |
| Obvious of (int * int) |
|
39 |
(*| Hyper of int list*) |
|
40 |
| Unusedstep of unit |
|
41 |
||
42 |
||
43 |
datatype Clausesimp = Binary_s of int * int |
|
44 |
| Factor_s of unit |
|
45 |
| Demod_s of (int * int) list |
|
46 |
| Hyper_s of int list |
|
47 |
| Unusedstep_s of unit |
|
48 |
||
49 |
||
50 |
||
51 |
datatype Step_label = T_info |
|
52 |
|P_info |
|
53 |
||
54 |
||
55 |
fun is_alpha_space_digit_or_neg ch = (ch = "~") orelse (is_alpha ch) orelse (is_digit ch) orelse ( ch = " ") |
|
56 |
||
57 |
||
58 |
||
15697 | 59 |
fun lit_string_with_nums t = let val termstr = Term.string_of_term t |
15642 | 60 |
val exp_term = explode termstr |
61 |
in |
|
62 |
implode(List.filter is_alpha_space_digit_or_neg exp_term) |
|
63 |
end |
|
64 |
||
65 |
||
66 |
(****************************************) |
|
67 |
(* Reconstruct an axiom resolution step *) |
|
68 |
(****************************************) |
|
69 |
||
70 |
fun follow_axiom clauses allvars (clausenum:int) thml clause_strs = |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
71 |
let val this_axiom =(Recon_Base.assoc clausenum clauses) |
15642 | 72 |
val (res, numlist, symlist, nsymlist) = (rearrange_clause this_axiom clause_strs allvars) |
73 |
val thmvars = thm_vars res |
|
74 |
in |
|
75 |
(res, (Axiom,clause_strs,thmvars ) ) |
|
76 |
end |
|
77 |
||
78 |
(****************************************) |
|
79 |
(* Reconstruct a binary resolution step *) |
|
80 |
(****************************************) |
|
81 |
||
82 |
(* numbers of clauses and literals*) (*vars*) (*list of current thms*) (* literal strings as parsed from spass *) |
|
83 |
fun follow_binary ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs |
|
84 |
= let |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
85 |
val thm1 = select_literal (lit1 + 1) (Recon_Base.assoc clause1 thml) |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
86 |
val thm2 = Recon_Base.assoc clause2 thml |
15642 | 87 |
val res = thm1 RSN ((lit2 +1), thm2) |
88 |
val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars) |
|
89 |
val thmvars = thm_vars res |
|
90 |
in |
|
91 |
(res', ((Binary ((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars) ) |
|
92 |
end |
|
93 |
||
94 |
||
95 |
||
96 |
(******************************************************) |
|
97 |
(* Reconstruct a matching replacement resolution step *) |
|
98 |
(******************************************************) |
|
99 |
||
100 |
||
101 |
fun follow_mrr ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs |
|
102 |
= let |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
103 |
val thm1 = select_literal (lit1 + 1) (Recon_Base.assoc clause1 thml) |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
104 |
val thm2 = Recon_Base.assoc clause2 thml |
15642 | 105 |
val res = thm1 RSN ((lit2 +1), thm2) |
106 |
val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars) |
|
107 |
val thmvars = thm_vars res |
|
108 |
in |
|
109 |
(res', ((MRR ((clause1, lit1), (clause2 , lit2))) ,clause_strs,thmvars)) |
|
110 |
end |
|
111 |
||
112 |
||
113 |
(*******************************************) |
|
114 |
(* Reconstruct a factoring resolution step *) |
|
115 |
(*******************************************) |
|
116 |
||
117 |
fun mksubstlist [] sublist = sublist |
|
118 |
|mksubstlist ((a,b)::rest) sublist = let val vartype = type_of b |
|
119 |
val avar = Var(a,vartype) |
|
120 |
val newlist = ((avar,b)::sublist) in |
|
121 |
mksubstlist rest newlist |
|
122 |
end; |
|
123 |
||
124 |
(* based on Tactic.distinct_subgoals_tac *) |
|
125 |
||
126 |
fun delete_assump_tac state lit = |
|
127 |
let val (frozth,thawfn) = freeze_thaw state |
|
128 |
val froz_prems = cprems_of frozth |
|
129 |
val assumed = implies_elim_list frozth (map assume froz_prems) |
|
130 |
val new_prems = remove_nth lit froz_prems |
|
131 |
val implied = implies_intr_list new_prems assumed |
|
132 |
in |
|
133 |
Seq.single (thawfn implied) |
|
134 |
end |
|
135 |
||
136 |
||
137 |
||
138 |
||
139 |
||
140 |
(*************************************) |
|
141 |
(* Reconstruct a factoring step *) |
|
142 |
(*************************************) |
|
143 |
||
144 |
fun follow_factor clause lit1 lit2 allvars thml clause_strs= |
|
145 |
let |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
146 |
val th = Recon_Base.assoc clause thml |
15642 | 147 |
val prems = prems_of th |
15697 | 148 |
val sign = sign_of_thm th |
15642 | 149 |
val fac1 = get_nth (lit1+1) prems |
150 |
val fac2 = get_nth (lit2+1) prems |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
151 |
val unif_env = Unify.unifiers (Mainsign,Envir.empty 0, [(fac1, fac2)]) |
15642 | 152 |
val newenv = getnewenv unif_env |
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
153 |
val envlist = Envir.alist_of newenv |
15642 | 154 |
|
15697 | 155 |
val (t1,t2)::_ = mksubstlist envlist [] |
15642 | 156 |
in |
15697 | 157 |
if (is_Var t1) |
15642 | 158 |
then |
159 |
let |
|
15697 | 160 |
val str1 = lit_string_with_nums t1; |
161 |
val str2 = lit_string_with_nums t2; |
|
15642 | 162 |
val facthm = read_instantiate [(str1,str2)] th; |
163 |
val res = hd (Seq.list_of(delete_assump_tac facthm (lit1 + 1))) |
|
164 |
val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars) |
|
165 |
val thmvars = thm_vars res' |
|
166 |
in |
|
167 |
(res',((Factor (clause, lit1, lit2)),clause_strs,thmvars)) |
|
168 |
end |
|
169 |
else |
|
170 |
let |
|
15697 | 171 |
val str2 = lit_string_with_nums t1; |
172 |
val str1 = lit_string_with_nums t2; |
|
15642 | 173 |
val facthm = read_instantiate [(str1,str2)] th; |
174 |
val res = hd (Seq.list_of(delete_assump_tac facthm (lit1 + 1))) |
|
175 |
val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars) |
|
176 |
val thmvars = thm_vars res' |
|
177 |
in |
|
178 |
(res', ((Factor (clause, lit1, lit2)),clause_strs, thmvars)) |
|
179 |
end |
|
180 |
end; |
|
181 |
||
182 |
||
183 |
||
184 |
Goal "[| [|Q |] ==> False; [|P|] ==> False; Q; P|] ==> False"; |
|
185 |
val prems = it; |
|
186 |
br (hd prems) 1; |
|
187 |
br (hd(tl(tl prems))) 1; |
|
188 |
qed "merge"; |
|
189 |
||
190 |
||
191 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
192 |
fun get_unif_comb t eqterm = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
193 |
if ((type_of t) = (type_of eqterm)) |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
194 |
then t |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
195 |
else |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
196 |
let val _ $ rand = t |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
197 |
in get_unif_comb rand eqterm end; |
15642 | 198 |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
199 |
fun get_unif_lit t eqterm = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
200 |
if (can HOLogic.dest_eq t) |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
201 |
then |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
202 |
let val (lhs,rhs) = HOLogic.dest_eq(HOLogic.dest_Trueprop eqterm) |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
203 |
in lhs end |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
204 |
else |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
205 |
get_unif_comb t eqterm; |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
206 |
|
15642 | 207 |
|
208 |
||
209 |
(*************************************) |
|
210 |
(* Reconstruct a paramodulation step *) |
|
211 |
(*************************************) |
|
212 |
||
213 |
val rev_subst = rotate_prems 1 subst; |
|
214 |
val rev_ssubst = rotate_prems 1 ssubst; |
|
215 |
||
216 |
||
217 |
(* have changed from negate_nead to negate_head. God knows if this will actually work *) |
|
218 |
fun follow_standard_para ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs= |
|
219 |
let |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
220 |
val th1 = Recon_Base.assoc clause1 thml |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
221 |
val th2 = Recon_Base.assoc clause2 thml |
15642 | 222 |
val eq_lit_th = select_literal (lit1+1) th1 |
223 |
val mod_lit_th = select_literal (lit2+1) th2 |
|
224 |
val eqsubst = eq_lit_th RSN (2,rev_subst) |
|
225 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 eqsubst) |
|
226 |
val newth' =negate_head newth |
|
227 |
val (res, numlist, symlist, nsymlist) = (rearrange_clause newth' clause_strs allvars |
|
228 |
handle Not_in_list => let |
|
229 |
val mod_lit_th' = mod_lit_th RS not_sym |
|
230 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th')] 1 eqsubst) |
|
231 |
val newth' =negate_head newth |
|
232 |
in |
|
233 |
(rearrange_clause newth' clause_strs allvars) |
|
234 |
end) |
|
235 |
val thmvars = thm_vars res |
|
236 |
in |
|
237 |
(res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars)) |
|
238 |
end |
|
239 |
||
240 |
(* |
|
241 |
fun follow_standard_para ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs= |
|
242 |
let |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
243 |
val th1 = Recon_Base.assoc clause1 thml |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
244 |
val th2 = Recon_Base.assoc clause2 thml |
15642 | 245 |
val eq_lit_th = select_literal (lit1+1) th1 |
246 |
val mod_lit_th = select_literal (lit2+1) th2 |
|
247 |
val eqsubst = eq_lit_th RSN (2,rev_subst) |
|
248 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 eqsubst) |
|
249 |
val newth' =negate_nead newth |
|
250 |
val (res, numlist, symlist, nsymlist) = (rearrange_clause newth' clause_strs allvars) |
|
251 |
val thmvars = thm_vars res |
|
252 |
in |
|
253 |
(res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars)) |
|
254 |
end |
|
255 |
||
256 |
*) |
|
257 |
||
258 |
||
259 |
(********************************) |
|
260 |
(* Reconstruct a rewriting step *) |
|
261 |
(********************************) |
|
262 |
||
263 |
(* |
|
264 |
||
265 |
val rev_subst = rotate_prems 1 subst; |
|
266 |
||
267 |
fun paramod_rule ((cl1, lit1), (cl2 , lit2)) = |
|
268 |
let val eq_lit_th = select_literal (lit1+1) cl1 |
|
269 |
val mod_lit_th = select_literal (lit2+1) cl2 |
|
270 |
val eqsubst = eq_lit_th RSN (2,rev_subst) |
|
271 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 |
|
272 |
eqsubst) |
|
15697 | 273 |
in Meson.negated_asm_of_head newth end; |
15642 | 274 |
|
275 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 |
|
276 |
eqsubst) |
|
277 |
||
278 |
val mod_lit_th' = mod_lit_th RS not_sym |
|
279 |
||
280 |
*) |
|
281 |
||
282 |
||
283 |
fun delete_assumps 0 th = th |
|
284 |
| delete_assumps n th = let val th_prems = length (prems_of th) |
|
285 |
val th' = hd (Seq.list_of(delete_assump_tac th (th_prems -1))) |
|
286 |
in |
|
287 |
delete_assumps (n-1) th' |
|
288 |
end |
|
289 |
||
290 |
(* extra conditions from the equality turn up as 2nd to last literals of result. Need to delete them *) |
|
291 |
(* changed negate_nead to negate_head here too*) |
|
292 |
(* clause1, lit1 is thing to rewrite with *) |
|
293 |
fun follow_rewrite ((clause1, lit1), (clause2, lit2)) allvars thml clause_strs= |
|
294 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
295 |
let val th1 = Recon_Base.assoc clause1 thml |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
296 |
val th2 = Recon_Base.assoc clause2 thml |
15642 | 297 |
val eq_lit_th = select_literal (lit1+1) th1 |
298 |
val mod_lit_th = select_literal (lit2+1) th2 |
|
299 |
val eqsubst = eq_lit_th RSN (2,rev_subst) |
|
300 |
val eq_lit_prem_num = length (prems_of eq_lit_th) |
|
301 |
val sign = Sign.merge (sign_of_thm th1, sign_of_thm th2) |
|
302 |
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 |
|
303 |
eqsubst) |
|
304 |
||
305 |
val newthm = negate_head newth |
|
306 |
val newthm' = delete_assumps eq_lit_prem_num newthm |
|
307 |
val (res, numlist, symlist, nsymlist) =(rearrange_clause newthm clause_strs allvars) |
|
308 |
val thmvars = thm_vars res |
|
309 |
in |
|
310 |
(res, ((Rewrite ((clause1, lit1), (clause2, lit2))),clause_strs,thmvars)) |
|
311 |
end |
|
312 |
||
313 |
||
314 |
||
315 |
(*****************************************) |
|
316 |
(* Reconstruct an obvious reduction step *) |
|
317 |
(*****************************************) |
|
318 |
||
319 |
||
320 |
fun follow_obvious (clause1, lit1) allvars thml clause_strs= |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
321 |
let val th1 = Recon_Base.assoc clause1 thml |
15642 | 322 |
val prems1 = prems_of th1 |
323 |
val newthm = refl RSN ((lit1+ 1), th1) |
|
324 |
handle THM _ => hd (Seq.list_of(delete_assump_tac th1 (lit1 + 1))) |
|
325 |
val (res, numlist, symlist, nsymlist) =(rearrange_clause newthm clause_strs allvars) |
|
326 |
val thmvars = thm_vars res |
|
327 |
in |
|
328 |
(res, ((Obvious (clause1, lit1)),clause_strs,thmvars)) |
|
329 |
end |
|
330 |
||
331 |
(**************************************************************************************) |
|
332 |
(* reconstruct a single line of the res. proof - depending on what sort of proof step it was*) |
|
333 |
(**************************************************************************************) |
|
334 |
||
335 |
fun follow_proof clauses allvars clausenum thml (Axiom ) clause_strs |
|
336 |
= follow_axiom clauses allvars clausenum thml clause_strs |
|
337 |
||
338 |
| follow_proof clauses allvars clausenum thml (Binary (a, b)) clause_strs |
|
339 |
= follow_binary (a, b) allvars thml clause_strs |
|
340 |
||
341 |
| follow_proof clauses allvars clausenum thml (MRR (a, b)) clause_strs |
|
342 |
= follow_mrr (a, b) allvars thml clause_strs |
|
343 |
||
344 |
| follow_proof clauses allvars clausenum thml (Factor (a, b, c)) clause_strs |
|
345 |
= follow_factor a b c allvars thml clause_strs |
|
346 |
||
347 |
| follow_proof clauses allvars clausenum thml (Para (a, b)) clause_strs |
|
348 |
= follow_standard_para (a, b) allvars thml clause_strs |
|
349 |
||
350 |
| follow_proof clauses allvars clausenum thml (Rewrite (a,b)) clause_strs |
|
351 |
= follow_rewrite (a,b) allvars thml clause_strs |
|
352 |
||
353 |
| follow_proof clauses allvars clausenum thml (Obvious (a,b)) clause_strs |
|
354 |
= follow_obvious (a,b) allvars thml clause_strs |
|
355 |
||
356 |
(*| follow_proof clauses clausenum thml (Hyper l) |
|
357 |
= follow_hyper l thml*) |
|
358 |
| follow_proof clauses allvars clausenum thml _ _ = |
|
359 |
raise ASSERTION "proof step not implemented" |
|
360 |
||
361 |
||
362 |
||
363 |
||
364 |
(**************************************************************************************) |
|
365 |
(* reconstruct a single line of the res. proof - at the moment do only inference steps*) |
|
366 |
(**************************************************************************************) |
|
367 |
||
368 |
fun follow_line clauses allvars thml (clause_num, proof_step, clause_strs) recons |
|
369 |
= let |
|
370 |
val (thm, recon_fun) = follow_proof clauses allvars clause_num thml proof_step clause_strs |
|
371 |
val recon_step = (recon_fun) |
|
372 |
in |
|
373 |
(((clause_num, thm)::thml), ((clause_num,recon_step)::recons)) |
|
374 |
end |
|
375 |
||
376 |
(***************************************************************) |
|
377 |
(* follow through the res. proof, creating an Isabelle theorem *) |
|
378 |
(***************************************************************) |
|
379 |
||
380 |
||
381 |
||
382 |
(*fun is_proof_char ch = (case ch of |
|
383 |
||
384 |
"(" => true |
|
385 |
| ")" => true |
|
386 |
| ":" => true |
|
387 |
| "'" => true |
|
388 |
| "&" => true |
|
389 |
| "|" => true |
|
390 |
| "~" => true |
|
391 |
| "." => true |
|
392 |
|(is_alpha ) => true |
|
393 |
|(is_digit) => true |
|
394 |
| _ => false)*) |
|
395 |
||
396 |
fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126)) orelse (ch = " ") |
|
397 |
||
398 |
fun proofstring x = let val exp = explode x |
|
399 |
in |
|
400 |
List.filter (is_proof_char ) exp |
|
401 |
end |
|
402 |
||
403 |
||
404 |
fun not_newline ch = not (ch = "\n"); |
|
405 |
||
406 |
fun concat_with_and [] str = str |
|
407 |
| concat_with_and (x::[]) str = str^"("^x^")" |
|
408 |
| concat_with_and (x::xs) str = (concat_with_and xs (str^"("^x^")"^" & ")) |
|
409 |
(* |
|
410 |
||
411 |
fun follow clauses [] allvars thml recons = |
|
412 |
let (* val _ = reset show_sorts*) |
|
413 |
val thmstring = concat_with_and (map string_of_thm (map snd thml)) "" |
|
414 |
val thmproofstring = proofstring ( thmstring) |
|
415 |
val no_returns =List.filter not_newline ( thmproofstring) |
|
416 |
val thmstr = implode no_returns |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
417 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "thml_file"))) |
15642 | 418 |
val _ = TextIO.output(outfile, "thmstr is "^thmstr) |
419 |
val _ = TextIO.flushOut outfile; |
|
420 |
val _ = TextIO.closeOut outfile |
|
421 |
(*val _ = set show_sorts*) |
|
422 |
in |
|
423 |
((snd( hd thml)), recons) |
|
424 |
end |
|
425 |
| follow clauses (h::t) allvars thml recons |
|
426 |
= let |
|
427 |
val (thml', recons') = follow_line clauses allvars thml h recons |
|
428 |
val (thm, recons_list) = follow clauses t allvars thml' recons' |
|
429 |
||
430 |
||
431 |
in |
|
432 |
(thm,recons_list) |
|
433 |
end |
|
434 |
||
435 |
*) |
|
436 |
||
437 |
fun replace_clause_strs [] recons newrecons= (newrecons) |
|
438 |
| replace_clause_strs ((thmnum, thm)::thml) ((clausenum,(step,clause_strs,thmvars))::recons) newrecons = |
|
439 |
let val new_clause_strs = get_meta_lits_bracket thm |
|
440 |
in |
|
441 |
replace_clause_strs thml recons ((clausenum,(step,new_clause_strs,thmvars))::newrecons) |
|
442 |
end |
|
443 |
||
444 |
||
445 |
fun follow clauses [] allvars thml recons = |
|
446 |
let |
|
447 |
val new_recons = replace_clause_strs thml recons [] |
|
448 |
in |
|
449 |
((snd( hd thml)), new_recons) |
|
450 |
end |
|
451 |
||
452 |
| follow clauses (h::t) allvars thml recons |
|
453 |
= let |
|
454 |
val (thml', recons') = follow_line clauses allvars thml h recons |
|
455 |
val (thm, recons_list) = follow clauses t allvars thml' recons' |
|
456 |
in |
|
457 |
(thm,recons_list) |
|
458 |
end |
|
459 |
||
460 |
||
461 |
||
462 |
(* Assume we have the cnf clauses as a list of (clauseno, clause) *) |
|
463 |
(* and the proof as a list of the proper datatype *) |
|
464 |
(* take the cnf clauses of the goal and the proof from the res. prover *) |
|
465 |
(* as a list of type Proofstep and return the thm goal ==> False *) |
|
466 |
||
467 |
fun first_pair (a,b,c) = (a,b); |
|
468 |
||
469 |
fun second_pair (a,b,c) = (b,c); |
|
470 |
||
471 |
(* takes original axioms, proof_steps parsed from spass, variables *) |
|
472 |
||
473 |
fun translate_proof clauses proof allvars |
|
474 |
= let val (thm, recons) = follow clauses proof allvars [] [] |
|
475 |
in |
|
476 |
(thm, (recons)) |
|
477 |
end |
|
478 |
||
479 |
||
480 |
||
481 |
fun remove_tinfo [] = [] |
|
482 |
| remove_tinfo ( (clausenum, step, T_info, newstrs)::xs) = (clausenum, step , newstrs)::(remove_tinfo xs) |