author | paulson |
Thu, 21 Apr 2005 10:05:06 +0200 | |
changeset 15787 | 8fad4bd4e53c |
parent 15782 | a1863ea9052b |
child 15789 | 4cb16144c81b |
permissions | -rw-r--r-- |
15642 | 1 |
(******************) |
2 |
(* complete later *) |
|
3 |
(******************) |
|
4 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
5 |
structure Recon_Transfer = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
6 |
struct |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
7 |
|
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
8 |
open Recon_Parse |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
9 |
infixr 8 ++; infixr 7 >>; infixr 6 ||; |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
10 |
|
15642 | 11 |
fun not_newline ch = not (ch = "\n"); |
12 |
||
13 |
||
14 |
||
15 |
(* Versions that include type information *) |
|
16 |
||
17 |
fun string_of_thm thm = let val _ = set show_sorts |
|
15787 | 18 |
val str = Display.string_of_thm thm |
15642 | 19 |
val no_returns =List.filter not_newline (explode str) |
20 |
val _ = reset show_sorts |
|
21 |
in |
|
22 |
implode no_returns |
|
23 |
end |
|
24 |
||
25 |
||
26 |
fun thm_of_string str = let val _ = set show_sorts |
|
27 |
val term = read str |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
28 |
val propterm = HOLogic.mk_Trueprop term |
15642 | 29 |
val cterm = cterm_of Mainsign propterm |
30 |
val _ = reset show_sorts |
|
31 |
in |
|
32 |
assume cterm |
|
33 |
end |
|
34 |
||
35 |
(* check separate args in the watcher program for separating strings with a * or ; or something *) |
|
36 |
||
37 |
fun clause_strs_to_string [] str = str |
|
38 |
| clause_strs_to_string (x::xs) str = clause_strs_to_string xs (str^x^"%") |
|
39 |
||
40 |
||
41 |
||
42 |
fun thmvars_to_string [] str = str |
|
43 |
| thmvars_to_string (x::xs) str = thmvars_to_string xs (str^x^"%") |
|
44 |
||
45 |
||
46 |
fun proofstep_to_string Axiom = "Axiom()" |
|
47 |
| proofstep_to_string (Binary ((a,b), (c,d)))= "Binary"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")" |
|
48 |
| proofstep_to_string (Factor (a,b,c)) = "Factor"^"("^(string_of_int a)^","^(string_of_int b)^","^(string_of_int c)^")" |
|
49 |
| proofstep_to_string (Para ((a,b), (c,d)))= "Para"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")" |
|
50 |
| proofstep_to_string (MRR ((a,b), (c,d)))= "MRR"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")" |
|
51 |
| proofstep_to_string (Rewrite((a,b),(c,d))) = "Rewrite"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")" |
|
52 |
||
53 |
fun list_to_string [] liststr = liststr |
|
54 |
| list_to_string (x::[]) liststr = liststr^(string_of_int x) |
|
55 |
| list_to_string (x::xs) liststr = list_to_string xs (liststr^(string_of_int x)^",") |
|
56 |
||
57 |
||
58 |
fun proof_to_string (num,(step,clause_strs, thmvars)) = (string_of_int num)^(proofstep_to_string step)^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]" |
|
59 |
||
60 |
||
61 |
fun proofs_to_string [] str = str |
|
62 |
| proofs_to_string (x::xs) str = let val newstr = proof_to_string x |
|
63 |
in |
|
64 |
proofs_to_string xs (str^newstr) |
|
65 |
end |
|
66 |
||
67 |
||
68 |
||
69 |
fun init_proofstep_to_string (num, step, clause_strs) = (string_of_int num)^" "^(proofstep_to_string step)^" "^(clause_strs_to_string clause_strs "")^" " |
|
70 |
||
71 |
fun init_proofsteps_to_string [] str = str |
|
72 |
| init_proofsteps_to_string (x::xs) str = let val newstr = init_proofstep_to_string x |
|
73 |
in |
|
74 |
init_proofsteps_to_string xs (str^newstr) |
|
75 |
end |
|
76 |
||
77 |
||
78 |
||
79 |
(*** get a string representing the Isabelle ordered axioms ***) |
|
80 |
||
81 |
fun origAx_to_string (num,(meta,thmvars)) =let val clause_strs = get_meta_lits_bracket meta |
|
82 |
in |
|
83 |
(string_of_int num)^"OrigAxiom()"^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]" |
|
84 |
end |
|
85 |
||
86 |
||
87 |
fun origAxs_to_string [] str = str |
|
88 |
| origAxs_to_string (x::xs) str = let val newstr = origAx_to_string x |
|
89 |
in |
|
90 |
origAxs_to_string xs (str^newstr) |
|
91 |
end |
|
92 |
||
93 |
||
94 |
(*** get a string representing the Isabelle ordered axioms not used in the spass proof***) |
|
95 |
||
96 |
fun extraAx_to_string (num, (meta,thmvars)) = let val clause_strs = get_meta_lits_bracket meta |
|
97 |
in |
|
98 |
(string_of_int num)^"ExtraAxiom()"^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]" |
|
99 |
end |
|
100 |
||
101 |
||
102 |
||
103 |
fun extraAxs_to_string [] str = str |
|
104 |
| extraAxs_to_string (x::xs) str = let val newstr = extraAx_to_string x |
|
105 |
in |
|
106 |
extraAxs_to_string xs (str^newstr) |
|
107 |
end |
|
108 |
||
109 |
||
110 |
||
111 |
fun is_axiom ( num:int,Axiom, str) = true |
|
112 |
| is_axiom (num, _,_) = false |
|
113 |
||
114 |
fun get_init_axioms xs = List.filter (is_axiom) ( xs) |
|
115 |
||
116 |
fun get_step_nums [] nums = nums |
|
117 |
| get_step_nums (( num:int,Axiom, str)::xs) nums = get_step_nums xs (nums@[num]) |
|
118 |
||
15774 | 119 |
exception Noassoc; |
120 |
||
121 |
fun assoc_snd a [] = raise Noassoc |
|
15642 | 122 |
| assoc_snd a ((x, y)::t) = if a = y then x else assoc_snd a t; |
123 |
||
124 |
(* change to be something using check_order instead of a = y --> returns true if ASSERTION not raised in checkorder, false otherwise *) |
|
125 |
||
126 |
(*fun get_assoc_snds [] xs assocs= assocs |
|
127 |
| get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_snd x ys))]) |
|
128 |
*) |
|
129 |
(*FIX - should this have vars in it? *) |
|
15774 | 130 |
fun there_out_of_order xs ys = (checkorder xs ys [] ([],[],[]); true) |
131 |
handle _ => false |
|
15642 | 132 |
|
15774 | 133 |
fun assoc_out_of_order a [] = raise Noassoc |
15642 | 134 |
| assoc_out_of_order a ((b,c)::t) = if there_out_of_order a c then b else assoc_out_of_order a t; |
135 |
||
136 |
fun get_assoc_snds [] xs assocs= assocs |
|
137 |
| get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_out_of_order x ys))]) |
|
138 |
||
139 |
||
140 |
||
141 |
||
142 |
fun add_if_not_inlist [] xs newlist = newlist |
|
143 |
| add_if_not_inlist (y::ys) xs newlist = if (not (inlist y xs)) then |
|
144 |
add_if_not_inlist ys xs (y::newlist) |
|
145 |
else add_if_not_inlist ys xs (newlist) |
|
146 |
||
15700 | 147 |
(*Flattens a list of list of strings to one string*) |
148 |
fun onestr ls = String.concat (map String.concat ls); |
|
15642 | 149 |
|
150 |
fun thmstrings [] str = str |
|
151 |
| thmstrings (x::xs) str = thmstrings xs (str^(string_of_thm x)) |
|
152 |
||
153 |
||
15782 | 154 |
fun get_axioms_used proof_steps thms = let |
155 |
(*val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_ax_thmstr"))) |
|
15642 | 156 |
val _ = TextIO.output (outfile, thmstring) |
157 |
||
15782 | 158 |
val _ = TextIO.closeOut outfile*) |
15642 | 159 |
(* not sure why this is necessary again, but seems to be *) |
15782 | 160 |
|
15642 | 161 |
val _= (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
162 |
val axioms = get_init_axioms proof_steps |
|
163 |
val step_nums = get_step_nums axioms [] |
|
15782 | 164 |
|
165 |
||
166 |
val clauses = make_clauses thms |
|
15642 | 167 |
|
168 |
val vars = map thm_vars clauses |
|
169 |
||
170 |
val distvars = distinct (fold append vars []) |
|
171 |
val clause_terms = map prop_of clauses |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
172 |
val clause_frees = List.concat (map term_frees clause_terms) |
15642 | 173 |
|
174 |
val frees = map lit_string_with_nums clause_frees; |
|
175 |
||
176 |
val distfrees = distinct frees |
|
177 |
||
15697 | 178 |
val metas = map Meson.make_meta_clause clauses |
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
179 |
val ax_strs = map #3 axioms |
15642 | 180 |
|
181 |
(* literals of -all- axioms, not just those used by spass *) |
|
182 |
val meta_strs = map get_meta_lits metas |
|
183 |
||
15774 | 184 |
val metas_and_strs = ListPair.zip (metas,meta_strs) |
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
185 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_clauses"))); |
15700 | 186 |
val _ = TextIO.output (outfile, onestr ax_strs) |
15642 | 187 |
|
188 |
val _ = TextIO.closeOut outfile |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
189 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_metastrs"))); |
15700 | 190 |
val _ = TextIO.output (outfile, onestr meta_strs) |
15642 | 191 |
val _ = TextIO.closeOut outfile |
192 |
||
193 |
(* get list of axioms as thms with their variables *) |
|
194 |
||
195 |
val ax_metas = get_assoc_snds ax_strs metas_and_strs [] |
|
196 |
val ax_vars = map thm_vars ax_metas |
|
15774 | 197 |
val ax_with_vars = ListPair.zip (ax_metas,ax_vars) |
15642 | 198 |
|
199 |
(* get list of extra axioms as thms with their variables *) |
|
200 |
val extra_metas = add_if_not_inlist metas ax_metas [] |
|
201 |
val extra_vars = map thm_vars extra_metas |
|
202 |
val extra_with_vars = if (not (extra_metas = []) ) |
|
203 |
then |
|
15774 | 204 |
ListPair.zip (extra_metas,extra_vars) |
15642 | 205 |
else |
206 |
[] |
|
207 |
||
208 |
(* val _= (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
209 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_metas"))) |
15642 | 210 |
|
211 |
val _ = TextIO.output (outfile, ((thmstrings ax_metas ""))) |
|
212 |
val _ = TextIO.closeOut outfile |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
213 |
val foo_metas = File.sysify_path(File.tmp_path (Path.basic "foo_metas")) |
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
214 |
val foo_metas2 = File.sysify_path(File.tmp_path (Path.basic "foo_metas2")) |
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
215 |
val execperl = Unix.execute("/usr/bin/perl", ["remchars.pl", " <", foo_metas, " >", foo_metas2]) |
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
216 |
val infile = TextIO.openIn(File.sysify_path(File.tmp_path (Path.basic "foo_metas2"))) |
15642 | 217 |
val ax_metas_str = TextIO.inputLine (infile) |
218 |
val _ = TextIO.closeIn infile |
|
219 |
val _= (print_mode := (["xsymbols", "symbols"] @ ! print_mode))*) |
|
220 |
||
221 |
in |
|
15774 | 222 |
(distfrees,distvars, extra_with_vars,ax_with_vars, (ListPair.zip (step_nums,ax_metas))) |
15642 | 223 |
end |
224 |
||
225 |
fun numclstr (vars, []) str = str |
|
226 |
| numclstr ( vars, ((num, thm)::rest)) str = let val newstr = str^(string_of_int num)^" "^(string_of_thm thm)^" " |
|
227 |
in |
|
228 |
numclstr (vars,rest) newstr |
|
229 |
end |
|
230 |
||
231 |
(* |
|
232 |
||
233 |
val proofstr = "Did parsing on Here is a proof with depth 4, length 9 :\ |
|
234 |
\1[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*+ -> v_P(tconst_fun(typ__da_a,tconst_bool),U)*.\ |
|
235 |
\3[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),U)*+ -> v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*.\ |
|
236 |
\5[0:Inp] || -> v_P(tconst_fun(typ__da_a,tconst_bool),U)* v_P(tconst_fun(typ__da_a,tconst_bool),v_xa)*.\ |
|
237 |
\7[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),U)*+ v_P(tconst_fun(typ__da_a,tconst_bool),v_xb)* -> .\ |
|
238 |
\9[0:Fac:5.0,5.1] || -> v_P(tconst_fun(typ__da_a,tconst_bool),v_xa)*.\ |
|
239 |
\10[0:Res:9.0,3.0] || -> v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*.\ |
|
240 |
\11[0:Res:10.0,1.0] || -> v_P(tconst_fun(typ__da_a,tconst_bool),U)*.\ |
|
241 |
\12[0:Fac:7.0,7.1] || v_P(tconst_fun(typ__da_a,tconst_bool),v_xb)* -> .\ |
|
242 |
\14[0:Res:11.0,12.0] || -> .\ |
|
243 |
\Formulae used in the proof :" |
|
244 |
||
245 |
*) |
|
246 |
||
247 |
||
248 |
fun addvars c (a,b) = (a,b,c) |
|
249 |
||
250 |
||
251 |
||
252 |
(*********************************************************************) |
|
253 |
(* Pass in spass string of proof and string version of isabelle goal *) |
|
254 |
(* Get out reconstruction steps as a string to be sent to Isabelle *) |
|
255 |
(*********************************************************************) |
|
256 |
||
257 |
||
258 |
(* |
|
259 |
||
260 |
||
261 |
val proofstr = "Here is a proof with depth 2, length 5 :\ |
|
262 |
\1[0:Inp] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\ |
|
263 |
\3[0:Inp] || v_Q(tconst_fun(typ__asc39_a,tconst_bool),U)* -> .\ |
|
264 |
\5[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)* -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa).\ |
|
265 |
\7[0:Res:1.0,5.0] || -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\ |
|
266 |
\9[0:Res:7.0,3.0] || -> .\ |
|
267 |
\Formulae used in the proof :" |
|
268 |
||
269 |
||
270 |
val proofstr = "Here is a proof with depth 4, length 9 :\ |
|
271 |
\1[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*+ -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\ |
|
272 |
\3[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*+ -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*.\ |
|
273 |
\5[0:Inp] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)* v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\ |
|
274 |
\7[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*+ v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xb)* -> .\ |
|
275 |
\9[0:Fac:5.0,5.1] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\ |
|
276 |
\10[0:Res:9.0,3.0] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*.\ |
|
277 |
\11[0:Res:10.0,1.0] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\ |
|
278 |
\12[0:Fac:7.0,7.1] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xb)* -> .\ |
|
279 |
\14[0:Res:11.0,12.0] || -> .\ |
|
280 |
\Formulae used in the proof :"; |
|
281 |
||
282 |
||
283 |
val thmstring = " (~ (P::'a::type => bool) (x::'a::type) | P (U::'a::type)) & (~ (P::'a::type => bool) (U::'a::type) | P (x::'a::type)) & ((P::'a::type => bool) (xa::'a::type) | P (U::'a::type)) & (~ (P::'a::type => bool) (U::'a::type) | ~ P (xb::'a::type))"; |
|
284 |
||
285 |
val thmstring = "(ALL xb::'a::type. (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) | (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) & P xb & ~ Q xb)" |
|
286 |
||
287 |
||
288 |
val thmstring ="(ALL xb::'a::type. (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) | (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) & P xb & ~ Q xb)" |
|
289 |
||
290 |
val proofstr = "Did parsing on Here is a proof with depth 2, length 5 :\ |
|
291 |
\1[0:Inp] || -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\ |
|
292 |
\3[0:Inp] || v_Q(tconst_fun(typ__asc39_a,tconst_bool),U)* -> .\ |
|
293 |
\5[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x(tconst_fun(typ__asc39_a,typ__asc39_a),U))* -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa(tconst_fun(typ__asc39_a,typ__asc39_a),U)).\ |
|
294 |
\7[0:Res:1.0,5.0] || -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa(tconst_fun(typ__asc39_a,typ__asc39_a),U))*.\ |
|
295 |
\9[0:Res:7.0,3.0] || -> .\ |
|
296 |
\Formulae used in the proof :"; |
|
297 |
||
298 |
*) |
|
299 |
||
15782 | 300 |
val dummy_tac = PRIMITIVE(fn thm => thm ); |
15642 | 301 |
|
15782 | 302 |
fun spassString_to_reconString proofstr thmstring goalstring toParent ppid thms= |
303 |
let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "thmstringfile"))); |
|
304 |
(* val sign = sign_of_thm thm |
|
305 |
val prems = prems_of thm |
|
306 |
val prems_string = concat_with_and (map (Sign.string_of_term sign) prems) "" |
|
307 |
val _ = warning ("thmstring is: "^thmstring);(*("thm in spassStrtoRec: "^(concat_with_and (map string_of_thm thms) "")^*)*) |
|
308 |
val _ = TextIO.output (outfile, (" thmstring is: "^thmstring^"proofstr is: "^proofstr)) |
|
309 |
(*val _ = TextIO.output (outfile, (("in spassStrto Reconstr")));*) |
|
15642 | 310 |
val _ = TextIO.closeOut outfile |
15782 | 311 |
|
312 |
val tokens = #1(lex proofstr) |
|
313 |
||
15642 | 314 |
|
315 |
(***********************************) |
|
316 |
(* parse spass proof into datatype *) |
|
317 |
(***********************************) |
|
318 |
||
319 |
val proof_steps1 = parse tokens |
|
320 |
val proof_steps = just_change_space proof_steps1 |
|
321 |
||
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
322 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_parse"))); val _ = TextIO.output (outfile, ("Did parsing on "^proofstr)) |
15642 | 323 |
val _ = TextIO.closeOut outfile |
324 |
||
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
325 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_thmstring_at_parse"))); val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring)) |
15642 | 326 |
val _ = TextIO.closeOut outfile |
327 |
(************************************) |
|
328 |
(* recreate original subgoal as thm *) |
|
329 |
(************************************) |
|
330 |
||
331 |
(* get axioms as correctly numbered clauses w.r.t. the Spass proof *) |
|
15782 | 332 |
(* need to get prems_of thm, then get right one of the prems, relating to whichever*) |
333 |
(* subgoal this is, and turn it into meta_clauses *) |
|
334 |
val (frees,vars,extra_with_vars ,ax_with_vars,numcls) = get_axioms_used proof_steps thms |
|
15642 | 335 |
|
336 |
(*val numcls_string = numclstr ( vars, numcls) ""*) |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
337 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_axiom"))); val _ = TextIO.output (outfile,"got axioms") |
15642 | 338 |
val _ = TextIO.closeOut outfile |
339 |
||
340 |
(************************************) |
|
341 |
(* translate proof *) |
|
342 |
(************************************) |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
343 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_steps"))); val _ = TextIO.output (outfile, ("about to translate proof, steps: "^(init_proofsteps_to_string proof_steps ""))) |
15642 | 344 |
val _ = TextIO.closeOut outfile |
345 |
val (newthm,proof) = translate_proof numcls proof_steps vars |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
346 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_steps2"))); val _ = TextIO.output (outfile, ("translated proof, steps: "^(init_proofsteps_to_string proof_steps ""))) |
15642 | 347 |
val _ = TextIO.closeOut outfile |
348 |
(***************************************************) |
|
349 |
(* transfer necessary steps as strings to Isabelle *) |
|
350 |
(***************************************************) |
|
351 |
(* turn the proof into a string *) |
|
352 |
val reconProofStr = proofs_to_string proof "" |
|
353 |
(* do the bit for the Isabelle ordered axioms at the top *) |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
354 |
val ax_nums = map #1 numcls |
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
355 |
val ax_strs = map get_meta_lits_bracket (map #2 numcls) |
15774 | 356 |
val numcls_strs = ListPair.zip (ax_nums,ax_strs) |
15642 | 357 |
val num_cls_vars = map (addvars vars) numcls_strs; |
15774 | 358 |
val reconIsaAxStr = origAxs_to_string (ListPair.zip (ax_nums,ax_with_vars)) "" |
15642 | 359 |
|
360 |
val extra_nums = if (not (extra_with_vars = [])) then (1 upto (length extra_with_vars)) else [] |
|
15774 | 361 |
val reconExtraAxStr = extraAxs_to_string ( ListPair.zip (extra_nums,extra_with_vars)) "" |
15642 | 362 |
val frees_str = "["^(thmvars_to_string frees "")^"]" |
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
363 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "reconstringfile"))); |
15642 | 364 |
|
365 |
val _ = TextIO.output (outfile, (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)) |
|
366 |
val _ = TextIO.closeOut outfile |
|
15782 | 367 |
val reconstr = (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr) |
15642 | 368 |
in |
15782 | 369 |
TextIO.output (toParent, reconstr^"\n"); |
370 |
TextIO.flushOut toParent; |
|
371 |
TextIO.output (toParent, thmstring^"\n"); |
|
372 |
TextIO.flushOut toParent; |
|
373 |
TextIO.output (toParent, goalstring^"\n"); |
|
374 |
TextIO.flushOut toParent; |
|
375 |
||
376 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
377 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
378 |
OS.Process.sleep(Time.fromSeconds 1) ; dummy_tac |
|
15642 | 379 |
end |
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
380 |
handle _ => (let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_handler"))); |
15642 | 381 |
|
382 |
val _ = TextIO.output (outfile, ("In exception handler")); |
|
383 |
val _ = TextIO.closeOut outfile |
|
384 |
in |
|
15782 | 385 |
TextIO.output (toParent,"Proof found but translation failed!" ^"\n"); |
386 |
TextIO.flushOut toParent; |
|
387 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
388 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
389 |
OS.Process.sleep(Time.fromSeconds 1) ;dummy_tac |
|
15642 | 390 |
end) |
391 |
||
392 |
||
393 |
||
394 |
||
395 |
||
396 |
||
397 |
||
398 |
||
399 |
||
400 |
(**********************************************************************************) |
|
401 |
(* At other end, want to turn back into datatype so can apply reconstruct_proof. *) |
|
402 |
(* This will be done by the signal handler *) |
|
403 |
(**********************************************************************************) |
|
404 |
||
405 |
(* Parse in the string version of the proof steps for reconstruction *) |
|
406 |
(* Isar format: cl1 [BINARY 0 cl2 0];cl1 [PARAMOD 0 cl2 0]; cl1 [DEMOD 0 cl2];cl1 [FACTOR 1 2];*) |
|
407 |
||
408 |
||
409 |
val term_numstep = |
|
410 |
(number ++ (a (Other ",")) ++ number) >> (fn (a, (_, c)) => (a, c)) |
|
411 |
||
412 |
val extraaxiomstep = (a (Word "ExtraAxiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
413 |
>> (fn (_) => ExtraAxiom) |
|
414 |
||
415 |
||
416 |
||
417 |
val origaxiomstep = (a (Word "OrigAxiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
418 |
>> (fn (_) => OrigAxiom) |
|
419 |
||
420 |
||
421 |
val axiomstep = (a (Word "Axiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
422 |
>> (fn (_) => Axiom) |
|
423 |
||
424 |
||
425 |
||
426 |
||
427 |
val binarystep = (a (Word "Binary")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
428 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
429 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
430 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Binary (c,e)) |
|
431 |
||
432 |
||
433 |
val parastep = (a (Word "Para")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
434 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
435 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
436 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Para(c, e)) |
|
437 |
||
438 |
val mrrstep = (a (Word "MRR")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
439 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
440 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
441 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => MRR(c, e)) |
|
442 |
||
443 |
||
444 |
val factorstep = (a (Word "Factor")) ++ (a (Other "(")) |
|
445 |
++ number ++ (a (Other ",")) |
|
446 |
++ number ++ (a (Other ",")) |
|
447 |
++ number ++ (a (Other ")")) |
|
448 |
||
449 |
>> (fn (_, (_, (c, (_, (e,(_,(f,_))))))) => Factor (c,e,f)) |
|
450 |
||
451 |
||
452 |
val rewritestep = (a (Word "Rewrite")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
453 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
454 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
455 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Rewrite (c,e)) |
|
456 |
||
457 |
val obviousstep = (a (Word "Obvious")) ++ (a (Other "(")) |
|
458 |
++ term_numstep ++ (a (Other ")")) |
|
459 |
>> (fn (_, (_, (c,_))) => Obvious (c)) |
|
460 |
||
461 |
val methodstep = extraaxiomstep || origaxiomstep || axiomstep ||binarystep || factorstep|| parastep || mrrstep || rewritestep || obviousstep |
|
462 |
||
463 |
||
464 |
val number_list_step = |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
465 |
( number ++ many ((a (Other ",") ++ number)>> #2)) |
15642 | 466 |
>> (fn (a,b) => (a::b)) |
467 |
||
468 |
val numberlist_step = a (Other "[") ++ a (Other "]") |
|
469 |
>>(fn (_,_) => ([]:int list)) |
|
470 |
|| a (Other "[") ++ number_list_step ++ a (Other "]") |
|
471 |
>>(fn (_,(a,_)) => a) |
|
472 |
||
473 |
||
474 |
||
475 |
(** change this to allow P (x U) *) |
|
476 |
fun arglist_step input = ( word ++ many word >> (fn (a, b) => (a^" "^(implode_with_space b))) |
|
477 |
||word >> (fn (a) => (a)))input |
|
478 |
||
479 |
||
480 |
fun literal_step input = (word ++ a (Other "(") ++ arglist_step ++ a (Other ")") |
|
481 |
>>(fn (a, (b, (c,d))) => (a^" ("^(c)^")")) |
|
482 |
|| arglist_step >> (fn (a) => (a)))input |
|
483 |
||
484 |
||
485 |
||
486 |
(* fun term_step input = (a (Other "~") ++ arglist_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b)) |
|
487 |
|| arglist_step ++ a (Other "%")>> (fn (a,b) => a ))input |
|
488 |
*) |
|
489 |
||
490 |
||
491 |
fun term_step input = (a (Other "~") ++ literal_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b)) |
|
492 |
|| literal_step ++ a (Other "%")>> (fn (a,b) => a ))input |
|
493 |
||
494 |
||
495 |
||
496 |
||
497 |
val term_list_step = |
|
498 |
( term_step ++ many ( term_step)) |
|
499 |
>> (fn (a,b) => (a::b)) |
|
500 |
||
501 |
||
502 |
val term_lists_step = a (Other "[") ++ a (Other "]") |
|
503 |
>>(fn (_,_) => ([]:string list)) |
|
504 |
|| a (Other "[") ++ term_list_step ++ a (Other "]") |
|
505 |
>>(fn (_,(a,_)) => a) |
|
506 |
||
507 |
||
508 |
||
509 |
||
510 |
fun anytoken_step input = (word>> (fn (a) => a) ) input |
|
511 |
handle NOPARSE_WORD => (number>> (fn (a) => string_of_int a) ) input |
|
512 |
handle NOPARSE_NUMBER => (other_char >> (fn(a) => a)) input |
|
513 |
||
514 |
||
515 |
||
516 |
fun goalstring_step input= (anytoken_step ++ many (anytoken_step ) |
|
517 |
>> (fn (a,b) => (a^" "^(implode b)))) input |
|
518 |
||
519 |
||
520 |
||
521 |
val linestep = number ++ methodstep ++ term_lists_step ++ term_lists_step |
|
522 |
>> (fn (a, (b, (c,d))) => (a,(b,c,d))) |
|
523 |
||
524 |
val lines_step = many linestep |
|
525 |
||
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
526 |
val alllines_step = (term_lists_step ++ lines_step ) ++ finished >> #1 |
15642 | 527 |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
528 |
val parse_step = #1 o alllines_step |
15642 | 529 |
|
530 |
||
531 |
(* |
|
532 |
val reconstr ="[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]%(EX x::'a::type. ALL y::'a::type. (P::'a::type => bool) x = P y) -->(EX x::'a::type. P x) = (ALL y::'a::type. P y)" |
|
533 |
*) |
|
534 |
||
535 |
(************************************************************) |
|
536 |
(* Construct an Isar style proof from a list of proof steps *) |
|
537 |
(************************************************************) |
|
538 |
(* want to assume all axioms, then do haves for the other clauses*) |
|
539 |
(* then show for the last step *) |
|
540 |
||
541 |
(* replace ~ by not here *) |
|
542 |
fun change_nots [] = [] |
|
543 |
| change_nots (x::xs) = if x = "~" |
|
544 |
then |
|
545 |
["\\", "<", "n", "o", "t", ">"]@(change_nots xs) |
|
546 |
else (x::(change_nots xs)) |
|
547 |
||
548 |
(* |
|
549 |
fun clstrs_to_string [] str = str |
|
550 |
| clstrs_to_string (x::[]) str = str^x |
|
551 |
| clstrs_to_string (x::xs) str = clstrs_to_string xs (str^(x^"; ")) |
|
552 |
*) |
|
553 |
fun clstrs_to_string [] str = implode (change_nots (explode str)) |
|
554 |
| clstrs_to_string (x::[]) str = implode (change_nots (explode (str^x))) |
|
555 |
| clstrs_to_string (x::xs) str = implode (change_nots (explode (clstrs_to_string xs (str^(x^"; "))))) |
|
556 |
||
557 |
||
558 |
||
559 |
fun thmvars_to_quantstring [] str = str |
|
560 |
| thmvars_to_quantstring (x::[]) str =str^x^". " |
|
561 |
| thmvars_to_quantstring (x::xs) str = thmvars_to_quantstring xs (str^(x^" ")) |
|
562 |
||
563 |
||
564 |
fun clause_strs_to_isar clstrs [] = "\"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> "^" \\<Longrightarrow> False\"" |
|
565 |
| clause_strs_to_isar clstrs thmvars = "\"\\<And>"^(thmvars_to_quantstring thmvars "")^"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> "^"\\<Longrightarrow> False\"" |
|
566 |
||
567 |
fun frees_to_string [] str = implode (change_nots (explode str)) |
|
568 |
| frees_to_string (x::[]) str = implode (change_nots (explode (str^x))) |
|
569 |
| frees_to_string (x::xs) str = implode (change_nots (explode (frees_to_string xs (str^(x^" "))))) |
|
570 |
||
571 |
fun frees_to_isar_str [] = "" |
|
572 |
| frees_to_isar_str clstrs = (frees_to_string clstrs "") |
|
573 |
||
574 |
||
575 |
(***********************************************************************) |
|
576 |
(* functions for producing assumptions for the Isabelle ordered axioms *) |
|
577 |
(***********************************************************************) |
|
578 |
(*val str = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]"; |
|
579 |
num, rule, clausestrs, vars*) |
|
580 |
||
581 |
||
582 |
(* assume the extra clauses - not used in Spass proof *) |
|
583 |
||
584 |
fun is_extraaxiom_step ( num:int,(ExtraAxiom, str, tstr)) = true |
|
585 |
| is_extraaxiom_step (num, _) = false |
|
586 |
||
587 |
fun get_extraaxioms xs = List.filter (is_extraaxiom_step) ( xs) |
|
588 |
||
589 |
fun assume_isar_extraaxiom [] str = str |
|
590 |
| assume_isar_extraaxiom ((numb,(step, clstr, thmvars))::xs) str = assume_isar_extraaxiom xs (str^"and cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstr thmvars)^"\n " ) |
|
591 |
||
592 |
||
593 |
||
594 |
fun assume_isar_extraaxioms [] = "" |
|
595 |
|assume_isar_extraaxioms ((numb,(step, clstrs, thmstrs))::xs) = let val str = "assume cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
596 |
in |
|
597 |
assume_isar_extraaxiom xs str |
|
598 |
end |
|
599 |
||
600 |
(* assume the Isabelle ordered clauses *) |
|
601 |
||
602 |
fun is_origaxiom_step ( num:int,(OrigAxiom, str, tstr)) = true |
|
603 |
| is_origaxiom_step (num, _) = false |
|
604 |
||
605 |
fun get_origaxioms xs = List.filter (is_origaxiom_step) ( xs) |
|
606 |
||
607 |
fun assume_isar_origaxiom [] str = str |
|
608 |
| assume_isar_origaxiom ((numb,(step, clstr, thmvars))::xs) str = assume_isar_origaxiom xs (str^"and cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstr thmvars)^"\n " ) |
|
609 |
||
610 |
||
611 |
||
612 |
fun assume_isar_origaxioms ((numb,(step, clstrs, thmstrs))::xs) = let val str = "assume cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
613 |
in |
|
614 |
assume_isar_origaxiom xs str |
|
615 |
end |
|
616 |
||
617 |
||
618 |
||
619 |
fun is_axiom_step ( num:int,(Axiom, str, tstr)) = true |
|
620 |
| is_axiom_step (num, _) = false |
|
621 |
||
622 |
fun get_axioms xs = List.filter (is_axiom_step) ( xs) |
|
623 |
||
624 |
fun have_isar_axiomline (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
625 |
||
626 |
fun by_isar_axiomline (numb,(step, clstrs, thmstrs))="by (rule cl"^ (string_of_int numb)^"') \n" |
|
627 |
||
628 |
||
629 |
fun isar_axiomline (numb, (step, clstrs, thmstrs)) = (have_isar_axiomline (numb,(step,clstrs, thmstrs )))^( by_isar_axiomline(numb,(step,clstrs, thmstrs )) ) |
|
630 |
||
631 |
||
632 |
fun isar_axiomlines [] str = str |
|
633 |
| isar_axiomlines (x::xs) str = isar_axiomlines xs (str^(isar_axiomline x)) |
|
634 |
||
635 |
||
636 |
fun have_isar_line (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
637 |
||
638 |
||
639 |
fun by_isar_line ((Binary ((a,b), (c,d))))="by(rule cl"^ |
|
640 |
(string_of_int a)^" [BINARY "^(string_of_int b)^" "^"cl"^ |
|
641 |
(string_of_int c)^" "^(string_of_int d)^"])"^"\n" |
|
642 |
| by_isar_line ( (Para ((a,b), (c,d)))) ="by (rule cl"^ |
|
643 |
(string_of_int a)^" [PARAMOD "^(string_of_int b)^" "^"cl"^ |
|
644 |
(string_of_int c)^" "^(string_of_int d)^"])"^"\n" |
|
645 |
| by_isar_line ((Factor ((a,b,c)))) = "by (rule cl"^(string_of_int a)^" [FACTOR "^(string_of_int b)^" "^ |
|
646 |
(string_of_int c)^" "^"])"^"\n" |
|
647 |
| by_isar_line ( (Rewrite ((a,b),(c,d)))) = "by (rule cl"^(string_of_int a)^" [DEMOD "^(string_of_int b)^" "^ |
|
648 |
(string_of_int c)^" "^(string_of_int d)^" "^"])"^"\n" |
|
649 |
||
650 |
| by_isar_line ( (Obvious ((a,b)))) = "by (rule cl"^(string_of_int a)^" [OBVIOUS "^(string_of_int b)^" ])"^"\n" |
|
651 |
||
652 |
fun isar_line (numb, (step, clstrs, thmstrs)) = (have_isar_line (numb,(step,clstrs, thmstrs )))^( by_isar_line step) |
|
653 |
||
654 |
||
655 |
fun isar_lines [] str = str |
|
656 |
| isar_lines (x::xs) str = isar_lines xs (str^(isar_line x)) |
|
657 |
||
658 |
fun last_isar_line (numb,( step, clstrs,thmstrs)) = "show \"False\"\n"^(by_isar_line step) |
|
659 |
||
660 |
||
661 |
fun to_isar_proof (frees, xs, goalstring) = let val extraaxioms = get_extraaxioms xs |
|
662 |
val extraax_num = length extraaxioms |
|
15774 | 663 |
val origaxioms_and_steps = Library.drop (extraax_num, xs) |
15642 | 664 |
|
665 |
||
666 |
val origaxioms = get_origaxioms origaxioms_and_steps |
|
667 |
val origax_num = length origaxioms |
|
15774 | 668 |
val axioms_and_steps = Library.drop (origax_num + extraax_num, xs) |
15642 | 669 |
val axioms = get_axioms axioms_and_steps |
670 |
||
15774 | 671 |
val steps = Library.drop (origax_num, axioms_and_steps) |
15642 | 672 |
val firststeps = butlast steps |
673 |
val laststep = last steps |
|
674 |
val goalstring = implode(butlast(explode goalstring)) |
|
675 |
||
676 |
val isar_proof = |
|
677 |
("show \""^goalstring^"\"\n")^ |
|
678 |
("proof (rule ccontr,skolemize, make_clauses) \n")^ |
|
679 |
("fix "^(frees_to_isar_str frees)^"\n")^ |
|
680 |
(assume_isar_extraaxioms extraaxioms)^ |
|
681 |
(assume_isar_origaxioms origaxioms)^ |
|
682 |
(isar_axiomlines axioms "")^ |
|
683 |
(isar_lines firststeps "")^ |
|
684 |
(last_isar_line laststep)^ |
|
685 |
("qed") |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
686 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "isar_proof_file"))); |
15642 | 687 |
|
688 |
val _ = TextIO.output (outfile, isar_proof) |
|
689 |
val _ = TextIO.closeOut outfile |
|
690 |
||
691 |
||
692 |
in |
|
693 |
isar_proof |
|
694 |
end |
|
695 |
||
696 |
(* get fix vars from axioms - all Frees *) |
|
697 |
(* check each clause for meta-vars and /\ over them at each step*) |
|
698 |
||
699 |
(*******************************************************) |
|
700 |
(* This assumes the thm list "numcls" is still there *) |
|
701 |
(* In reality, should probably label it with an *) |
|
702 |
(* ID number identifying the subgoal. This could *) |
|
703 |
(* be passed over to the watcher, e.g. numcls25 *) |
|
704 |
(*******************************************************) |
|
705 |
||
706 |
(* val str = "[S%x%P%R%Q%]1ExtraAxiom()[~ Q U%~ R U%][U%]2ExtraAxiom()[~ Q U%~ P U%][U%]3ExtraAxiom()[Q U%R U%][U%]1OrigAxiom()[S x%][]2OrigAxiom()[P U%R U%][U%]6OrigAxiom()[~ S U%~ P U%][U%]7OrigAxiom()[~ S U%~ R U%][U%]1Axiom()[S x%][]2Axiom()[R U%P U%][U%]6Axiom()[~ P U%~ S U%][U%]7Axiom()[~ R U%~ S U%][U%]8Binary((6,1),(1,0))[~ P x%][]9Binary((7,1),(1,0))[~ R x%][]19Binary((9,0),(2,0))[P x%][]25Binary((8,0),(19,0))[][]"; |
|
707 |
||
708 |
val str = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]"; |
|
709 |
||
710 |
val reconstr = "[P%Q%x%xa%]1OrigAxiom()[~ P U%][U%]3OrigAxiom()[Q U%][U%]5OrigAxiom()[P (x U)%~ Q (xa U)%][U%]9Binary((7,0),(3,0))[][]7Binary((1,0),(5,0))[~ Q (xa U)%][U%]5Axiom()[P (x U)%~ Q (xa U)%][U%]3Axiom()[Q U%][U%]1Axiom()[~ P U%][U%](ALL xb::'a::type. (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) | (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) & P xb & ~ Q xb)"; |
|
711 |
||
712 |
||
713 |
val reconstr = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]"; |
|
714 |
||
715 |
val thmstring = " (ALL xa::'a::type. (~ (P::'a::type => bool) (x::'a::type) | P xa) & (~ P xa | P x)) & (((P::'a::type => bool) (xa::'a::type) | (ALL x::'a::type. P x)) &((ALL x::'a::type. ~ P x) | ~ P (xb::'a::type)))"; |
|
716 |
*) |
|
717 |
||
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
718 |
fun apply_res_thm str goalstring = let val tokens = #1 (lex str); |
15642 | 719 |
|
720 |
val (frees,recon_steps) = parse_step tokens |
|
721 |
val isar_str = to_isar_proof (frees, recon_steps, goalstring) |
|
15658
2edb384bf61f
watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents:
15642
diff
changeset
|
722 |
val foo = TextIO.openOut (File.sysify_path(File.tmp_path (Path.basic "foobar"))); |
15642 | 723 |
in |
724 |
TextIO.output(foo,(isar_str));TextIO.closeOut foo;Pretty.writeln(Pretty.str isar_str); () |
|
725 |
end |
|
726 |
||
727 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
728 |
end; |