author | quigley |
Fri, 10 Jun 2005 16:15:36 +0200 | |
changeset 16357 | f1275d2a1dee |
parent 16259 | aed1a8ae4b23 |
child 16478 | d0a1f6231e2f |
permissions | -rw-r--r-- |
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
1 |
(* ID: $Id$ |
16259 | 2 |
Author: Claire Quigley |
3 |
Copyright 2004 University of Cambridge |
|
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
4 |
*) |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15787
diff
changeset
|
5 |
|
15642 | 6 |
(******************) |
7 |
(* complete later *) |
|
8 |
(******************) |
|
9 |
||
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
10 |
structure Recon_Transfer = |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
11 |
struct |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
12 |
open Recon_Parse |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
13 |
infixr 8 ++; infixr 7 >>; infixr 6 ||; |
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
14 |
|
15642 | 15 |
fun not_newline ch = not (ch = "\n"); |
16 |
||
17 |
||
18 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
19 |
(* |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
20 |
fun fill_cls_array array n [] = () |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
21 |
| fill_cls_array array n (x::xs) = let val _ = Array.update (array, n,x) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
22 |
in |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
23 |
fill_cls_array array (n+1) (xs) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
24 |
end; |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
25 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
26 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
27 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
28 |
fun memo_add_clauses ((name:string, (cls:Thm.thm list)), symtable)= |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
29 |
symtable := Symtab.update((name , cls), !symtable); |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
30 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
31 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
32 |
fun memo_add_all ([], symtable) = () |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
33 |
| memo_add_all ((x::xs),symtable) = let val _ = memo_add_clauses (x, symtable) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
34 |
in |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
35 |
memo_add_all (xs, symtable) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
36 |
end |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
37 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
38 |
fun memo_find_clause (name, (symtable: Thm.thm list Symtab.table ref)) = case Symtab.lookup (!symtable,name) of |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
39 |
NONE => [] |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
40 |
|SOME cls => cls ; |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
41 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
42 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
43 |
fun retrieve_clause array symtable clausenum = let |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
44 |
val (name, clnum) = Array.sub(array, clausenum) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
45 |
val clauses = memo_find_clause (name, symtable) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
46 |
val clause = get_nth clnum clauses |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
47 |
in |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
48 |
(name, clause) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
49 |
end |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
50 |
*) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
51 |
|
15642 | 52 |
(* Versions that include type information *) |
53 |
||
16157 | 54 |
fun string_of_thm thm = |
55 |
let val _ = set show_sorts |
|
56 |
val str = Display.string_of_thm thm |
|
57 |
val no_returns =List.filter not_newline (explode str) |
|
58 |
val _ = reset show_sorts |
|
59 |
in |
|
60 |
implode no_returns |
|
61 |
end |
|
15642 | 62 |
|
63 |
||
64 |
(* check separate args in the watcher program for separating strings with a * or ; or something *) |
|
65 |
||
66 |
fun clause_strs_to_string [] str = str |
|
67 |
| clause_strs_to_string (x::xs) str = clause_strs_to_string xs (str^x^"%") |
|
68 |
||
69 |
fun thmvars_to_string [] str = str |
|
70 |
| thmvars_to_string (x::xs) str = thmvars_to_string xs (str^x^"%") |
|
71 |
||
72 |
||
73 |
fun proofstep_to_string Axiom = "Axiom()" |
|
16091 | 74 |
| proofstep_to_string (Binary ((a,b), (c,d)))= |
75 |
"Binary(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))" |
|
76 |
| proofstep_to_string (Factor (a,b,c)) = |
|
77 |
"Factor("^(string_of_int a)^","^(string_of_int b)^","^(string_of_int c)^")" |
|
78 |
| proofstep_to_string (Para ((a,b), (c,d)))= |
|
79 |
"Para(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))" |
|
80 |
| proofstep_to_string (MRR ((a,b), (c,d))) = |
|
81 |
"MRR(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))" |
|
82 |
| proofstep_to_string (Rewrite((a,b),(c,d))) = |
|
83 |
"Rewrite(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))" |
|
15642 | 84 |
|
85 |
fun list_to_string [] liststr = liststr |
|
86 |
| list_to_string (x::[]) liststr = liststr^(string_of_int x) |
|
87 |
| list_to_string (x::xs) liststr = list_to_string xs (liststr^(string_of_int x)^",") |
|
88 |
||
89 |
||
16091 | 90 |
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 "")^"]" |
15642 | 91 |
|
92 |
||
93 |
fun proofs_to_string [] str = str |
|
94 |
| proofs_to_string (x::xs) str = let val newstr = proof_to_string x |
|
95 |
in |
|
96 |
proofs_to_string xs (str^newstr) |
|
97 |
end |
|
98 |
||
99 |
||
100 |
||
101 |
fun init_proofstep_to_string (num, step, clause_strs) = (string_of_int num)^" "^(proofstep_to_string step)^" "^(clause_strs_to_string clause_strs "")^" " |
|
102 |
||
103 |
fun init_proofsteps_to_string [] str = str |
|
104 |
| init_proofsteps_to_string (x::xs) str = let val newstr = init_proofstep_to_string x |
|
105 |
in |
|
106 |
init_proofsteps_to_string xs (str^newstr) |
|
107 |
end |
|
108 |
||
109 |
||
110 |
||
111 |
(*** get a string representing the Isabelle ordered axioms ***) |
|
112 |
||
16061 | 113 |
fun origAx_to_string (num,(meta,thmvars)) = |
114 |
let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta |
|
115 |
in |
|
16091 | 116 |
(string_of_int num)^"OrigAxiom()["^ |
117 |
(clause_strs_to_string clause_strs "")^"]["^ |
|
16061 | 118 |
(thmvars_to_string thmvars "")^"]" |
119 |
end |
|
15642 | 120 |
|
121 |
||
122 |
fun origAxs_to_string [] str = str |
|
123 |
| origAxs_to_string (x::xs) str = let val newstr = origAx_to_string x |
|
124 |
in |
|
125 |
origAxs_to_string xs (str^newstr) |
|
126 |
end |
|
127 |
||
128 |
||
129 |
(*** get a string representing the Isabelle ordered axioms not used in the spass proof***) |
|
130 |
||
16061 | 131 |
fun extraAx_to_string (num, (meta,thmvars)) = |
132 |
let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta |
|
133 |
in |
|
16091 | 134 |
(string_of_int num)^"ExtraAxiom()["^ |
16061 | 135 |
(clause_strs_to_string clause_strs "")^"]"^ |
136 |
"["^(thmvars_to_string thmvars "")^"]" |
|
137 |
end; |
|
15642 | 138 |
|
16061 | 139 |
fun extraAxs_to_string [] str = str |
140 |
| extraAxs_to_string (x::xs) str = |
|
141 |
let val newstr = extraAx_to_string x |
|
142 |
in |
|
143 |
extraAxs_to_string xs (str^newstr) |
|
144 |
end; |
|
15642 | 145 |
|
146 |
fun is_axiom ( num:int,Axiom, str) = true |
|
147 |
| is_axiom (num, _,_) = false |
|
148 |
||
149 |
fun get_init_axioms xs = List.filter (is_axiom) ( xs) |
|
150 |
||
151 |
fun get_step_nums [] nums = nums |
|
152 |
| get_step_nums (( num:int,Axiom, str)::xs) nums = get_step_nums xs (nums@[num]) |
|
153 |
||
15774 | 154 |
exception Noassoc; |
155 |
||
156 |
fun assoc_snd a [] = raise Noassoc |
|
15642 | 157 |
| assoc_snd a ((x, y)::t) = if a = y then x else assoc_snd a t; |
158 |
||
159 |
(* change to be something using check_order instead of a = y --> returns true if ASSERTION not raised in checkorder, false otherwise *) |
|
160 |
||
161 |
(*fun get_assoc_snds [] xs assocs= assocs |
|
162 |
| get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_snd x ys))]) |
|
163 |
*) |
|
164 |
(*FIX - should this have vars in it? *) |
|
16061 | 165 |
fun there_out_of_order xs ys = (ReconOrderClauses.checkorder xs ys [] ([],[],[]); true) |
15774 | 166 |
handle _ => false |
15642 | 167 |
|
15774 | 168 |
fun assoc_out_of_order a [] = raise Noassoc |
15642 | 169 |
| assoc_out_of_order a ((b,c)::t) = if there_out_of_order a c then b else assoc_out_of_order a t; |
170 |
||
171 |
fun get_assoc_snds [] xs assocs= assocs |
|
172 |
| get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_out_of_order x ys))]) |
|
173 |
||
174 |
fun add_if_not_inlist [] xs newlist = newlist |
|
16157 | 175 |
| add_if_not_inlist (y::ys) xs newlist = if (not (y mem xs)) then |
15642 | 176 |
add_if_not_inlist ys xs (y::newlist) |
177 |
else add_if_not_inlist ys xs (newlist) |
|
178 |
||
15700 | 179 |
(*Flattens a list of list of strings to one string*) |
180 |
fun onestr ls = String.concat (map String.concat ls); |
|
15642 | 181 |
|
182 |
fun thmstrings [] str = str |
|
183 |
| thmstrings (x::xs) str = thmstrings xs (str^(string_of_thm x)) |
|
184 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
185 |
fun is_clasimp_ax clasimp_num n = n <=clasimp_num |
15642 | 186 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
187 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
188 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
189 |
fun retrieve_axioms clause_arr [] = [] |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
190 |
| retrieve_axioms clause_arr (x::xs) = [Array.sub(clause_arr, x)]@ |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
191 |
(retrieve_axioms clause_arr xs) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
192 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
193 |
fun subone x = x - 1 |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
194 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
195 |
fun numstr [] = "" |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
196 |
| numstr (x::xs) = (string_of_int x)^"%"^(numstr xs) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
197 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
198 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
199 |
(* retrieve the axioms that were obtained from the clasimpset *) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
200 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
201 |
fun get_clasimp_cls clause_arr clasimp_num step_nums = |
16157 | 202 |
let val realnums = map subone step_nums |
203 |
val clasimp_nums = List.filter (is_clasimp_ax (clasimp_num - 1)) realnums |
|
16259 | 204 |
val axnums = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "axnums"))) |
16157 | 205 |
val _ = TextIO.output(axnums,(numstr clasimp_nums)) |
206 |
val _ = TextIO.closeOut(axnums) |
|
207 |
in |
|
208 |
retrieve_axioms clause_arr clasimp_nums |
|
209 |
end |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
210 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
211 |
|
16357 | 212 |
|
213 |
(*****************************************************) |
|
214 |
(* get names of clasimp axioms used *) |
|
215 |
(*****************************************************) |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
216 |
|
16157 | 217 |
fun get_axiom_names proof_steps thms (clause_arr:(ResClause.clause * thm) Array.array) num_of_clauses = |
218 |
let |
|
219 |
(* not sure why this is necessary again, but seems to be *) |
|
220 |
val _ = (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
|
221 |
val axioms = get_init_axioms proof_steps |
|
222 |
val step_nums = get_step_nums axioms [] |
|
223 |
||
224 |
(***********************************************) |
|
225 |
(* here need to add the clauses from clause_arr*) |
|
226 |
(***********************************************) |
|
227 |
||
228 |
val (clasimp_names_cls) = get_clasimp_cls clause_arr num_of_clauses step_nums |
|
229 |
val clasimp_names = map (#1 o ResClause.clause_info o #1) clasimp_names_cls |
|
230 |
||
231 |
val _ = File.write (File.tmp_path (Path.basic "clasimp_names")) |
|
232 |
(concat clasimp_names) |
|
233 |
val _ = (print_mode := (["xsymbols", "symbols"] @ ! print_mode)) |
|
234 |
in |
|
235 |
clasimp_names |
|
236 |
end |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
237 |
|
16357 | 238 |
fun get_axiom_names_vamp proof_steps thms (clause_arr:(ResClause.clause * thm) Array.array) num_of_clauses = |
239 |
let |
|
240 |
(* not sure why this is necessary again, but seems to be *) |
|
241 |
val _ = (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
|
242 |
val axioms = get_init_axioms proof_steps |
|
243 |
val step_nums = get_step_nums axioms [] |
|
244 |
||
245 |
(***********************************************) |
|
246 |
(* here need to add the clauses from clause_arr*) |
|
247 |
(***********************************************) |
|
248 |
||
249 |
val (clasimp_names_cls) = get_clasimp_cls clause_arr num_of_clauses step_nums |
|
250 |
val clasimp_names = map (#1 o ResClause.clause_info o #1) clasimp_names_cls |
|
251 |
||
252 |
val _ = File.write (File.tmp_path (Path.basic "clasimp_names")) |
|
253 |
(concat clasimp_names) |
|
254 |
val _ = (print_mode := (["xsymbols", "symbols"] @ ! print_mode)) |
|
255 |
in |
|
256 |
clasimp_names |
|
257 |
end |
|
258 |
||
259 |
||
260 |
||
261 |
||
262 |
(***********************************************) |
|
263 |
(* get axioms for reconstruction *) |
|
264 |
(***********************************************) |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
265 |
fun numclstr (vars, []) str = str |
16157 | 266 |
| numclstr ( vars, ((num, thm)::rest)) str = |
267 |
let val newstr = str^(string_of_int num)^" "^(string_of_thm thm)^" " |
|
268 |
in |
|
269 |
numclstr (vars,rest) newstr |
|
270 |
end |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
271 |
|
16157 | 272 |
fun addvars c (a,b) = (a,b,c) |
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
273 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
274 |
fun get_axioms_used proof_steps thms clause_arr num_of_clauses = |
16061 | 275 |
let |
16259 | 276 |
(*val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_ax_thmstr"))) |
16061 | 277 |
val _ = TextIO.output (outfile, thmstring) |
278 |
||
279 |
val _ = TextIO.closeOut outfile*) |
|
280 |
(* not sure why this is necessary again, but seems to be *) |
|
15782 | 281 |
|
16061 | 282 |
val _= (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
283 |
val axioms = get_init_axioms proof_steps |
|
284 |
val step_nums = get_step_nums axioms [] |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
285 |
|
16061 | 286 |
(***********************************************) |
287 |
(* here need to add the clauses from clause_arr*) |
|
288 |
(***********************************************) |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
289 |
|
16061 | 290 |
(* val clasimp_names_cls = get_clasimp_cls clause_arr num_of_clauses step_nums |
291 |
val clasimp_names = map #1 clasimp_names_cls |
|
292 |
val clasimp_cls = map #2 clasimp_names_cls |
|
16259 | 293 |
val outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "clasimp_names"))) val clasimp_namestr = concat clasimp_names |
16061 | 294 |
val _ = TextIO.output (outfile,clasimp_namestr) |
295 |
||
296 |
val _ = TextIO.closeOut outfile |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
297 |
*) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
298 |
|
16061 | 299 |
val clauses =(*(clasimp_cls)@*)( make_clauses thms) |
300 |
||
301 |
val vars = map thm_vars clauses |
|
302 |
||
303 |
val distvars = distinct (fold append vars []) |
|
304 |
val clause_terms = map prop_of clauses |
|
305 |
val clause_frees = List.concat (map term_frees clause_terms) |
|
15642 | 306 |
|
16061 | 307 |
val frees = map lit_string_with_nums clause_frees; |
15642 | 308 |
|
16061 | 309 |
val distfrees = distinct frees |
15642 | 310 |
|
16061 | 311 |
val metas = map Meson.make_meta_clause clauses |
312 |
val ax_strs = map #3 axioms |
|
15642 | 313 |
|
16061 | 314 |
(* literals of -all- axioms, not just those used by spass *) |
315 |
val meta_strs = map ReconOrderClauses.get_meta_lits metas |
|
316 |
||
317 |
val metas_and_strs = ListPair.zip (metas,meta_strs) |
|
16259 | 318 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_clauses"))); |
16061 | 319 |
val _ = TextIO.output (outfile, onestr ax_strs) |
320 |
||
321 |
val _ = TextIO.closeOut outfile |
|
16259 | 322 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_metastrs"))); |
16061 | 323 |
val _ = TextIO.output (outfile, onestr meta_strs) |
324 |
val _ = TextIO.closeOut outfile |
|
15642 | 325 |
|
16061 | 326 |
(* get list of axioms as thms with their variables *) |
15642 | 327 |
|
16061 | 328 |
val ax_metas = get_assoc_snds ax_strs metas_and_strs [] |
329 |
val ax_vars = map thm_vars ax_metas |
|
330 |
val ax_with_vars = ListPair.zip (ax_metas,ax_vars) |
|
15642 | 331 |
|
16061 | 332 |
(* get list of extra axioms as thms with their variables *) |
333 |
val extra_metas = add_if_not_inlist metas ax_metas [] |
|
334 |
val extra_vars = map thm_vars extra_metas |
|
335 |
val extra_with_vars = if (not (extra_metas = []) ) |
|
336 |
then |
|
337 |
ListPair.zip (extra_metas,extra_vars) |
|
338 |
else |
|
339 |
[] |
|
15642 | 340 |
|
16061 | 341 |
(* val _= (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"]))) |
16259 | 342 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_metas"))) |
15642 | 343 |
|
16061 | 344 |
val _ = TextIO.output (outfile, ((thmstrings ax_metas ""))) |
345 |
val _ = TextIO.closeOut outfile |
|
16259 | 346 |
val foo_metas = File.platform_path(File.tmp_path (Path.basic "foo_metas")) |
347 |
val foo_metas2 = File.platform_path(File.tmp_path (Path.basic "foo_metas2")) |
|
16061 | 348 |
val execperl = Unix.execute("/usr/bin/perl", ["remchars.pl", " <", foo_metas, " >", foo_metas2]) |
16259 | 349 |
val infile = TextIO.openIn(File.platform_path(File.tmp_path (Path.basic "foo_metas2"))) |
16061 | 350 |
val ax_metas_str = TextIO.inputLine (infile) |
351 |
val _ = TextIO.closeIn infile |
|
352 |
val _= (print_mode := (["xsymbols", "symbols"] @ ! print_mode))*) |
|
353 |
||
354 |
in |
|
355 |
(distfrees,distvars, extra_with_vars,ax_with_vars, (*clasimp_names*)(ListPair.zip (step_nums,ax_metas))) |
|
356 |
end |
|
357 |
||
15642 | 358 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
359 |
|
15642 | 360 |
|
361 |
(*********************************************************************) |
|
362 |
(* Pass in spass string of proof and string version of isabelle goal *) |
|
363 |
(* Get out reconstruction steps as a string to be sent to Isabelle *) |
|
364 |
(*********************************************************************) |
|
365 |
||
366 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
367 |
fun rules_to_string [] str = str |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
368 |
| rules_to_string [x] str = str^x |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
369 |
| rules_to_string (x::xs) str = rules_to_string xs (str^x^" ") |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
370 |
|
15642 | 371 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
372 |
val dummy_tac = PRIMITIVE(fn thm => thm ); |
15642 | 373 |
|
374 |
||
16357 | 375 |
(*val proofstr = "1242[0:Inp] || -> equal(const_List_Orev(tconst_fun(tconst_List_Olist(U),tconst_List_Olist(U)),const_List_Olist_ONil),const_List_Olist_ONil)**.\ |
376 |
\1279[0:Inp] || -> equal(const_Nat_Osize(tconst_fun(tconst_List_Olist(U),tconst_nat),const_List_Olist_ONil),const_0)**.\ |
|
377 |
\1430[0:Inp] || equal(const_Nat_Osize(tconst_fun(tconst_List_Olist(typ__Ha),tconst_nat),const_List_Orev(tconst_fun(tconst_List_Olist(typ__Ha),tconst_List_Olist(typ__Ha)),const_List_Olist_ONil)),const_Nat_Osize(tconst_fun(tconst_List_Olist(typ__Ha),tconst_nat),const_List_Olist_ONil))** -> .\ |
|
378 |
\1453[0:Rew:1279.0,1430.0,1242.0,1430.0,1279.0,1430.0] || equal(const_0,const_0)* -> .\ |
|
379 |
\1454[0:Obv:1453.0] || -> .";*) |
|
380 |
||
381 |
fun remove_linebreaks str = let val strlist = explode str |
|
382 |
val nonewlines = filter (not_equal "\n") strlist |
|
383 |
in |
|
384 |
implode nonewlines |
|
385 |
end |
|
386 |
||
387 |
||
388 |
fun subst_for a b [] = "" |
|
389 |
| subst_for a b (x::xs) = if (x = a) |
|
390 |
then |
|
391 |
(b^(subst_for a b xs)) |
|
392 |
else |
|
393 |
x^(subst_for a b xs) |
|
394 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
395 |
|
16357 | 396 |
fun remove_linebreaks str = let val strlist = explode str |
397 |
in |
|
398 |
subst_for "\n" "\t" strlist |
|
399 |
end |
|
400 |
||
401 |
fun restore_linebreaks str = let val strlist = explode str |
|
402 |
in |
|
403 |
subst_for "\t" "\n" strlist |
|
404 |
end |
|
405 |
||
406 |
||
407 |
||
408 |
fun spassString_to_lemmaString proofstr thmstring goalstring toParent ppid thms clause_arr num_of_clauses = |
|
409 |
let val outfile = TextIO.openAppend( File.platform_path(File.tmp_path (Path.basic"thmstringfile"))); |
|
410 |
val _ = TextIO.output (outfile, ("thmstring is: "^thmstring^"\n proofstr is: "^proofstr^"\n goalstr is: "^goalstring^" \n num of clauses is: "^(string_of_int num_of_clauses))) |
|
411 |
||
412 |
val _ = TextIO.closeOut outfile |
|
413 |
||
414 |
(***********************************) |
|
415 |
(* parse spass proof into datatype *) |
|
416 |
(***********************************) |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
417 |
|
16357 | 418 |
val tokens = #1(lex proofstr) |
419 |
val proof_steps1 = parse tokens |
|
420 |
val proof_steps = just_change_space proof_steps1 |
|
421 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_parse"))); val _ = TextIO.output (outfile, ("Did parsing on "^proofstr)) |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
422 |
val _ = TextIO.closeOut outfile |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
423 |
|
16259 | 424 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_thmstring_at_parse"))); val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring)) |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
425 |
val _ = TextIO.closeOut outfile |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
426 |
(************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
427 |
(* recreate original subgoal as thm *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
428 |
(************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
429 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
430 |
(* get axioms as correctly numbered clauses w.r.t. the Spass proof *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
431 |
(* need to get prems_of thm, then get right one of the prems, relating to whichever*) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
432 |
(* subgoal this is, and turn it into meta_clauses *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
433 |
(* should prob add array and table here, so that we can get axioms*) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
434 |
(* produced from the clasimpset rather than the problem *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
435 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
436 |
val (axiom_names) = get_axiom_names proof_steps thms clause_arr num_of_clauses |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
437 |
val ax_str = "Rules from clasimpset used in proof found by SPASS: "^(rules_to_string axiom_names "") |
16259 | 438 |
val outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "reconstrfile"))); val _ = TextIO.output (outfile, ("reconstring is: "^ax_str^" "^goalstring)) |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
439 |
val _ = TextIO.closeOut outfile |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
440 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
441 |
in |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
442 |
TextIO.output (toParent, ax_str^"\n"); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
443 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
444 |
TextIO.output (toParent, "goalstring: "^goalstring^"\n"); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
445 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
446 |
TextIO.output (toParent, "thmstring: "^thmstring^"\n"); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
447 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
448 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
449 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
450 |
(* Attempt to prevent several signals from turning up simultaneously *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
451 |
Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
452 |
end |
16259 | 453 |
handle _ => (let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_handler"))); |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
454 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
455 |
val _ = TextIO.output (outfile, ("In exception handler")); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
456 |
val _ = TextIO.closeOut outfile |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
457 |
in |
16357 | 458 |
TextIO.output (toParent,"Proof found but parsing failed for resolution proof: "^(remove_linebreaks proofstr) ^"\n"); |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
459 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
460 |
TextIO.output (toParent, thmstring^"\n"); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
461 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
462 |
TextIO.output (toParent, goalstring^"\n"); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
463 |
TextIO.flushOut toParent; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
464 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
465 |
(* Attempt to prevent several signals from turning up simultaneously *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
466 |
Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16091
diff
changeset
|
467 |
end) |
15642 | 468 |
|
469 |
||
16357 | 470 |
(*fun vampString_to_lemmaString proofstr thmstring goalstring toParent ppid thms clause_arr num_of_clauses = |
471 |
let val outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "thmstringfile"))); val _ = TextIO.output (outfile, (" thmstring is: "^thmstring^"proofstr is: "^proofstr^"goalstr is: "^goalstring^" num of clauses is: "^(string_of_int num_of_clauses))) |
|
472 |
val _ = TextIO.closeOut outfile |
|
473 |
||
474 |
(***********************************) |
|
475 |
(* parse spass proof into datatype *) |
|
476 |
(***********************************) |
|
477 |
||
478 |
val tokens = #1(lex proofstr) |
|
479 |
val proof_steps = VampParse.parse tokens |
|
480 |
(*val proof_steps = just_change_space proof_steps1*) |
|
481 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_parse"))); val _ = TextIO.output (outfile, ("Did parsing on "^proofstr)) |
|
482 |
val _ = TextIO.closeOut outfile |
|
483 |
||
484 |
val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_thmstring_at_parse"))); val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring)) |
|
485 |
val _ = TextIO.closeOut outfile |
|
486 |
(************************************) |
|
487 |
(* recreate original subgoal as thm *) |
|
488 |
(************************************) |
|
489 |
||
490 |
(* get axioms as correctly numbered clauses w.r.t. the Spass proof *) |
|
491 |
(* need to get prems_of thm, then get right one of the prems, relating to whichever*) |
|
492 |
(* subgoal this is, and turn it into meta_clauses *) |
|
493 |
(* should prob add array and table here, so that we can get axioms*) |
|
494 |
(* produced from the clasimpset rather than the problem *) |
|
495 |
||
496 |
val (axiom_names) = get_axiom_names_vamp proof_steps thms clause_arr num_of_clauses |
|
497 |
val ax_str = "Rules from clasimpset used in proof found by SPASS: "^(rules_to_string axiom_names "") |
|
498 |
val outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "reconstrfile"))); val _ = TextIO.output (outfile, ("reconstring is: "^ax_str^" "^goalstring)) |
|
499 |
val _ = TextIO.closeOut outfile |
|
500 |
||
501 |
in |
|
502 |
TextIO.output (toParent, ax_str^"\n"); |
|
503 |
TextIO.flushOut toParent; |
|
504 |
TextIO.output (toParent, "goalstring: "^goalstring^"\n"); |
|
505 |
TextIO.flushOut toParent;fdsa |
|
506 |
TextIO.output (toParent, "thmstring: "^thmstring^"\n"); |
|
507 |
TextIO.flushOut toParent; |
|
508 |
||
509 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
510 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
511 |
Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac |
|
512 |
end |
|
513 |
handle _ => (let val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_handler"))); |
|
514 |
||
515 |
val _ = TextIO.output (outfile, ("In exception handler")); |
|
516 |
val _ = TextIO.closeOut outfile |
|
517 |
in |
|
518 |
TextIO.output (toParent,"Proof found but translation failed for resolution proof: \n"^(remove_linebreaks proofstr) ^"\n"); |
|
519 |
TextIO.flushOut toParent; |
|
520 |
TextIO.output (toParent, thmstring^"\n"); |
|
521 |
TextIO.flushOut toParent; |
|
522 |
TextIO.output (toParent, goalstring^"\n"); |
|
523 |
TextIO.flushOut toParent; |
|
524 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
525 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
526 |
Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac |
|
527 |
end) |
|
528 |
*) |
|
529 |
||
530 |
||
531 |
||
532 |
(* val proofstr = "1582[0:Inp] || -> v_P*.\ |
|
533 |
\1583[0:Inp] || v_P* -> .\ |
|
534 |
\1584[0:MRR:1583.0,1582.0] || -> ."; *) |
|
15642 | 535 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
536 |
fun spassString_to_reconString proofstr thmstring goalstring toParent ppid thms clause_arr num_of_clauses = |
16259 | 537 |
let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "thmstringfile"))); |
16061 | 538 |
(* val sign = sign_of_thm thm |
539 |
val prems = prems_of thm |
|
540 |
val prems_string = concat_with_and (map (Sign.string_of_term sign) prems) "" |
|
541 |
val _ = warning ("thmstring is: "^thmstring);(*("thm in spassStrtoRec: "^(concat_with_and (map string_of_thm thms) "")^*)*) |
|
542 |
val _ = TextIO.output (outfile, (" thmstring is: "^thmstring^"proofstr is: "^proofstr)) |
|
543 |
(*val _ = TextIO.output (outfile, (("in spassStrto Reconstr")));*) |
|
544 |
val _ = TextIO.closeOut outfile |
|
15782 | 545 |
|
16061 | 546 |
val tokens = #1(lex proofstr) |
15782 | 547 |
|
16061 | 548 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15817
diff
changeset
|
549 |
|
16061 | 550 |
(***********************************) |
551 |
(* parse spass proof into datatype *) |
|
552 |
(***********************************) |
|
15642 | 553 |
|
16061 | 554 |
val proof_steps1 = parse tokens |
555 |
val proof_steps = just_change_space proof_steps1 |
|
15642 | 556 |
|
16259 | 557 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_parse"))); val _ = TextIO.output (outfile, ("Did parsing on "^proofstr)) |
16061 | 558 |
val _ = TextIO.closeOut outfile |
559 |
||
16259 | 560 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_thmstring_at_parse"))); val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring)) |
16061 | 561 |
val _ = TextIO.closeOut outfile |
562 |
(************************************) |
|
563 |
(* recreate original subgoal as thm *) |
|
564 |
(************************************) |
|
565 |
||
566 |
(* get axioms as correctly numbered clauses w.r.t. the Spass proof *) |
|
567 |
(* need to get prems_of thm, then get right one of the prems, relating to whichever*) |
|
568 |
(* subgoal this is, and turn it into meta_clauses *) |
|
569 |
(* should prob add array and table here, so that we can get axioms*) |
|
570 |
(* produced from the clasimpset rather than the problem *) |
|
571 |
val (frees,vars,extra_with_vars ,ax_with_vars,numcls) = get_axioms_used proof_steps thms clause_arr num_of_clauses |
|
572 |
||
573 |
(*val numcls_string = numclstr ( vars, numcls) ""*) |
|
16259 | 574 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_axiom"))); val _ = TextIO.output (outfile,"got axioms") |
16061 | 575 |
val _ = TextIO.closeOut outfile |
576 |
||
577 |
(************************************) |
|
578 |
(* translate proof *) |
|
579 |
(************************************) |
|
16259 | 580 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_steps"))); val _ = TextIO.output (outfile, ("about to translate proof, steps: "^(init_proofsteps_to_string proof_steps ""))) |
16061 | 581 |
val _ = TextIO.closeOut outfile |
582 |
val (newthm,proof) = translate_proof numcls proof_steps vars |
|
16259 | 583 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_steps2"))); val _ = TextIO.output (outfile, ("translated proof, steps: "^(init_proofsteps_to_string proof_steps ""))) |
16061 | 584 |
val _ = TextIO.closeOut outfile |
585 |
(***************************************************) |
|
586 |
(* transfer necessary steps as strings to Isabelle *) |
|
587 |
(***************************************************) |
|
588 |
(* turn the proof into a string *) |
|
589 |
val reconProofStr = proofs_to_string proof "" |
|
590 |
(* do the bit for the Isabelle ordered axioms at the top *) |
|
591 |
val ax_nums = map #1 numcls |
|
592 |
val ax_strs = map ReconOrderClauses.get_meta_lits_bracket (map #2 numcls) |
|
593 |
val numcls_strs = ListPair.zip (ax_nums,ax_strs) |
|
594 |
val num_cls_vars = map (addvars vars) numcls_strs; |
|
595 |
val reconIsaAxStr = origAxs_to_string (ListPair.zip (ax_nums,ax_with_vars)) "" |
|
596 |
||
597 |
val extra_nums = if (not (extra_with_vars = [])) then (1 upto (length extra_with_vars)) else [] |
|
598 |
val reconExtraAxStr = extraAxs_to_string ( ListPair.zip (extra_nums,extra_with_vars)) "" |
|
599 |
val frees_str = "["^(thmvars_to_string frees "")^"]" |
|
16259 | 600 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "reconstringfile"))); |
15642 | 601 |
|
16061 | 602 |
val _ = TextIO.output (outfile, (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)) |
603 |
val _ = TextIO.closeOut outfile |
|
604 |
val reconstr = (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr) |
|
605 |
in |
|
606 |
TextIO.output (toParent, reconstr^"\n"); |
|
607 |
TextIO.flushOut toParent; |
|
608 |
TextIO.output (toParent, thmstring^"\n"); |
|
609 |
TextIO.flushOut toParent; |
|
610 |
TextIO.output (toParent, goalstring^"\n"); |
|
611 |
TextIO.flushOut toParent; |
|
612 |
||
613 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
614 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
615 |
Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac |
|
616 |
end |
|
16259 | 617 |
handle _ => (let val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_handler"))); |
15642 | 618 |
|
16061 | 619 |
val _ = TextIO.output (outfile, ("In exception handler")); |
620 |
val _ = TextIO.closeOut outfile |
|
621 |
in |
|
16357 | 622 |
TextIO.output (toParent,"Proof found but translation failed for resolution proof: \n"^proofstr ^"\n"); |
16061 | 623 |
TextIO.flushOut toParent; |
624 |
TextIO.output (toParent, thmstring^"\n"); |
|
625 |
TextIO.flushOut toParent; |
|
626 |
TextIO.output (toParent, goalstring^"\n"); |
|
627 |
TextIO.flushOut toParent; |
|
628 |
Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); |
|
629 |
(* Attempt to prevent several signals from turning up simultaneously *) |
|
630 |
Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac |
|
631 |
end) |
|
15642 | 632 |
|
633 |
||
634 |
||
635 |
||
636 |
||
637 |
(**********************************************************************************) |
|
638 |
(* At other end, want to turn back into datatype so can apply reconstruct_proof. *) |
|
639 |
(* This will be done by the signal handler *) |
|
640 |
(**********************************************************************************) |
|
641 |
||
642 |
(* Parse in the string version of the proof steps for reconstruction *) |
|
643 |
(* Isar format: cl1 [BINARY 0 cl2 0];cl1 [PARAMOD 0 cl2 0]; cl1 [DEMOD 0 cl2];cl1 [FACTOR 1 2];*) |
|
644 |
||
645 |
||
646 |
val term_numstep = |
|
647 |
(number ++ (a (Other ",")) ++ number) >> (fn (a, (_, c)) => (a, c)) |
|
648 |
||
649 |
val extraaxiomstep = (a (Word "ExtraAxiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
650 |
>> (fn (_) => ExtraAxiom) |
|
651 |
||
652 |
||
653 |
||
654 |
val origaxiomstep = (a (Word "OrigAxiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
655 |
>> (fn (_) => OrigAxiom) |
|
656 |
||
657 |
||
658 |
val axiomstep = (a (Word "Axiom"))++ (a (Other "(")) ++(a (Other ")")) |
|
659 |
>> (fn (_) => Axiom) |
|
660 |
||
661 |
||
662 |
||
663 |
||
664 |
val binarystep = (a (Word "Binary")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
665 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
666 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
667 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Binary (c,e)) |
|
668 |
||
669 |
||
670 |
val parastep = (a (Word "Para")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
671 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
672 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
673 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Para(c, e)) |
|
674 |
||
675 |
val mrrstep = (a (Word "MRR")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
676 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
677 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
678 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => MRR(c, e)) |
|
679 |
||
680 |
||
681 |
val factorstep = (a (Word "Factor")) ++ (a (Other "(")) |
|
682 |
++ number ++ (a (Other ",")) |
|
683 |
++ number ++ (a (Other ",")) |
|
684 |
++ number ++ (a (Other ")")) |
|
685 |
||
686 |
>> (fn (_, (_, (c, (_, (e,(_,(f,_))))))) => Factor (c,e,f)) |
|
687 |
||
688 |
||
689 |
val rewritestep = (a (Word "Rewrite")) ++ (a (Other "(")) ++ (a (Other "(")) |
|
690 |
++ term_numstep ++ (a (Other ")")) ++ (a (Other ",")) |
|
691 |
++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")")) |
|
692 |
>> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Rewrite (c,e)) |
|
693 |
||
694 |
val obviousstep = (a (Word "Obvious")) ++ (a (Other "(")) |
|
695 |
++ term_numstep ++ (a (Other ")")) |
|
696 |
>> (fn (_, (_, (c,_))) => Obvious (c)) |
|
697 |
||
698 |
val methodstep = extraaxiomstep || origaxiomstep || axiomstep ||binarystep || factorstep|| parastep || mrrstep || rewritestep || obviousstep |
|
699 |
||
700 |
||
701 |
val number_list_step = |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
702 |
( number ++ many ((a (Other ",") ++ number)>> #2)) |
15642 | 703 |
>> (fn (a,b) => (a::b)) |
704 |
||
705 |
val numberlist_step = a (Other "[") ++ a (Other "]") |
|
706 |
>>(fn (_,_) => ([]:int list)) |
|
707 |
|| a (Other "[") ++ number_list_step ++ a (Other "]") |
|
708 |
>>(fn (_,(a,_)) => a) |
|
709 |
||
710 |
||
711 |
||
712 |
(** change this to allow P (x U) *) |
|
713 |
fun arglist_step input = ( word ++ many word >> (fn (a, b) => (a^" "^(implode_with_space b))) |
|
714 |
||word >> (fn (a) => (a)))input |
|
715 |
||
716 |
||
717 |
fun literal_step input = (word ++ a (Other "(") ++ arglist_step ++ a (Other ")") |
|
718 |
>>(fn (a, (b, (c,d))) => (a^" ("^(c)^")")) |
|
719 |
|| arglist_step >> (fn (a) => (a)))input |
|
720 |
||
721 |
||
722 |
||
723 |
(* fun term_step input = (a (Other "~") ++ arglist_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b)) |
|
724 |
|| arglist_step ++ a (Other "%")>> (fn (a,b) => a ))input |
|
725 |
*) |
|
726 |
||
727 |
||
728 |
fun term_step input = (a (Other "~") ++ literal_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b)) |
|
729 |
|| literal_step ++ a (Other "%")>> (fn (a,b) => a ))input |
|
730 |
||
731 |
||
732 |
||
733 |
||
734 |
val term_list_step = |
|
735 |
( term_step ++ many ( term_step)) |
|
736 |
>> (fn (a,b) => (a::b)) |
|
737 |
||
738 |
||
739 |
val term_lists_step = a (Other "[") ++ a (Other "]") |
|
740 |
>>(fn (_,_) => ([]:string list)) |
|
741 |
|| a (Other "[") ++ term_list_step ++ a (Other "]") |
|
742 |
>>(fn (_,(a,_)) => a) |
|
743 |
||
744 |
||
745 |
||
746 |
||
747 |
fun anytoken_step input = (word>> (fn (a) => a) ) input |
|
748 |
handle NOPARSE_WORD => (number>> (fn (a) => string_of_int a) ) input |
|
749 |
handle NOPARSE_NUMBER => (other_char >> (fn(a) => a)) input |
|
750 |
||
751 |
||
752 |
||
753 |
fun goalstring_step input= (anytoken_step ++ many (anytoken_step ) |
|
754 |
>> (fn (a,b) => (a^" "^(implode b)))) input |
|
755 |
||
756 |
||
757 |
||
758 |
val linestep = number ++ methodstep ++ term_lists_step ++ term_lists_step |
|
759 |
>> (fn (a, (b, (c,d))) => (a,(b,c,d))) |
|
760 |
||
761 |
val lines_step = many linestep |
|
762 |
||
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
763 |
val alllines_step = (term_lists_step ++ lines_step ) ++ finished >> #1 |
15642 | 764 |
|
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
765 |
val parse_step = #1 o alllines_step |
15642 | 766 |
|
767 |
||
768 |
(* |
|
769 |
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)" |
|
770 |
*) |
|
771 |
||
772 |
(************************************************************) |
|
773 |
(* Construct an Isar style proof from a list of proof steps *) |
|
774 |
(************************************************************) |
|
775 |
(* want to assume all axioms, then do haves for the other clauses*) |
|
776 |
(* then show for the last step *) |
|
777 |
||
778 |
(* replace ~ by not here *) |
|
779 |
fun change_nots [] = [] |
|
780 |
| change_nots (x::xs) = if x = "~" |
|
781 |
then |
|
782 |
["\\", "<", "n", "o", "t", ">"]@(change_nots xs) |
|
783 |
else (x::(change_nots xs)) |
|
784 |
||
785 |
(* |
|
786 |
fun clstrs_to_string [] str = str |
|
787 |
| clstrs_to_string (x::[]) str = str^x |
|
788 |
| clstrs_to_string (x::xs) str = clstrs_to_string xs (str^(x^"; ")) |
|
789 |
*) |
|
790 |
fun clstrs_to_string [] str = implode (change_nots (explode str)) |
|
791 |
| clstrs_to_string (x::[]) str = implode (change_nots (explode (str^x))) |
|
792 |
| clstrs_to_string (x::xs) str = implode (change_nots (explode (clstrs_to_string xs (str^(x^"; "))))) |
|
793 |
||
794 |
||
795 |
||
796 |
fun thmvars_to_quantstring [] str = str |
|
797 |
| thmvars_to_quantstring (x::[]) str =str^x^". " |
|
798 |
| thmvars_to_quantstring (x::xs) str = thmvars_to_quantstring xs (str^(x^" ")) |
|
799 |
||
800 |
||
16091 | 801 |
fun clause_strs_to_isar clstrs [] = "\"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> \\<Longrightarrow> False\"" |
802 |
| clause_strs_to_isar clstrs thmvars = "\"\\<And>"^(thmvars_to_quantstring thmvars "")^"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> \\<Longrightarrow> False\"" |
|
15642 | 803 |
|
804 |
fun frees_to_string [] str = implode (change_nots (explode str)) |
|
805 |
| frees_to_string (x::[]) str = implode (change_nots (explode (str^x))) |
|
806 |
| frees_to_string (x::xs) str = implode (change_nots (explode (frees_to_string xs (str^(x^" "))))) |
|
807 |
||
808 |
fun frees_to_isar_str [] = "" |
|
809 |
| frees_to_isar_str clstrs = (frees_to_string clstrs "") |
|
810 |
||
811 |
||
812 |
(***********************************************************************) |
|
813 |
(* functions for producing assumptions for the Isabelle ordered axioms *) |
|
814 |
(***********************************************************************) |
|
815 |
(*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))[][]"; |
|
816 |
num, rule, clausestrs, vars*) |
|
817 |
||
818 |
||
819 |
(* assume the extra clauses - not used in Spass proof *) |
|
820 |
||
821 |
fun is_extraaxiom_step ( num:int,(ExtraAxiom, str, tstr)) = true |
|
822 |
| is_extraaxiom_step (num, _) = false |
|
823 |
||
824 |
fun get_extraaxioms xs = List.filter (is_extraaxiom_step) ( xs) |
|
825 |
||
826 |
fun assume_isar_extraaxiom [] str = str |
|
827 |
| 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 " ) |
|
828 |
||
829 |
||
830 |
||
831 |
fun assume_isar_extraaxioms [] = "" |
|
832 |
|assume_isar_extraaxioms ((numb,(step, clstrs, thmstrs))::xs) = let val str = "assume cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
833 |
in |
|
834 |
assume_isar_extraaxiom xs str |
|
835 |
end |
|
836 |
||
837 |
(* assume the Isabelle ordered clauses *) |
|
838 |
||
839 |
fun is_origaxiom_step ( num:int,(OrigAxiom, str, tstr)) = true |
|
840 |
| is_origaxiom_step (num, _) = false |
|
841 |
||
842 |
fun get_origaxioms xs = List.filter (is_origaxiom_step) ( xs) |
|
843 |
||
844 |
fun assume_isar_origaxiom [] str = str |
|
845 |
| 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 " ) |
|
846 |
||
847 |
||
848 |
||
849 |
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" |
|
850 |
in |
|
851 |
assume_isar_origaxiom xs str |
|
852 |
end |
|
853 |
||
854 |
||
855 |
||
856 |
fun is_axiom_step ( num:int,(Axiom, str, tstr)) = true |
|
857 |
| is_axiom_step (num, _) = false |
|
858 |
||
859 |
fun get_axioms xs = List.filter (is_axiom_step) ( xs) |
|
860 |
||
861 |
fun have_isar_axiomline (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
862 |
||
863 |
fun by_isar_axiomline (numb,(step, clstrs, thmstrs))="by (rule cl"^ (string_of_int numb)^"') \n" |
|
864 |
||
865 |
||
866 |
fun isar_axiomline (numb, (step, clstrs, thmstrs)) = (have_isar_axiomline (numb,(step,clstrs, thmstrs )))^( by_isar_axiomline(numb,(step,clstrs, thmstrs )) ) |
|
867 |
||
868 |
||
869 |
fun isar_axiomlines [] str = str |
|
870 |
| isar_axiomlines (x::xs) str = isar_axiomlines xs (str^(isar_axiomline x)) |
|
871 |
||
872 |
||
873 |
fun have_isar_line (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n" |
|
16357 | 874 |
(*FIX: ask Larry to add and mrr attribute *) |
15642 | 875 |
|
16091 | 876 |
fun by_isar_line ((Binary ((a,b), (c,d)))) = |
877 |
"by(rule cl"^ |
|
878 |
(string_of_int a)^" [binary "^(string_of_int b)^" cl"^ |
|
879 |
(string_of_int c)^" "^(string_of_int d)^"])\n" |
|
16357 | 880 |
|by_isar_line ((MRR ((a,b), (c,d)))) = |
881 |
"by(rule cl"^ |
|
882 |
(string_of_int a)^" [binary "^(string_of_int b)^" cl"^ |
|
883 |
(string_of_int c)^" "^(string_of_int d)^"])\n" |
|
16091 | 884 |
| by_isar_line ( (Para ((a,b), (c,d)))) = |
885 |
"by (rule cl"^ |
|
886 |
(string_of_int a)^" [paramod "^(string_of_int b)^" cl"^ |
|
887 |
(string_of_int c)^" "^(string_of_int d)^"])\n" |
|
888 |
| by_isar_line ((Factor ((a,b,c)))) = |
|
889 |
"by (rule cl"^(string_of_int a)^" [factor "^(string_of_int b)^" "^ |
|
890 |
(string_of_int c)^" ])\n" |
|
891 |
| by_isar_line ( (Rewrite ((a,b),(c,d)))) = |
|
892 |
"by (rule cl"^(string_of_int a)^" [demod "^(string_of_int b)^" "^ |
|
893 |
(string_of_int c)^" "^(string_of_int d)^" ])\n" |
|
894 |
| by_isar_line ( (Obvious ((a,b)))) = |
|
895 |
"by (rule cl"^(string_of_int a)^" [obvious "^(string_of_int b)^" ])\n" |
|
15642 | 896 |
|
897 |
fun isar_line (numb, (step, clstrs, thmstrs)) = (have_isar_line (numb,(step,clstrs, thmstrs )))^( by_isar_line step) |
|
898 |
||
899 |
||
900 |
fun isar_lines [] str = str |
|
901 |
| isar_lines (x::xs) str = isar_lines xs (str^(isar_line x)) |
|
902 |
||
903 |
fun last_isar_line (numb,( step, clstrs,thmstrs)) = "show \"False\"\n"^(by_isar_line step) |
|
904 |
||
905 |
||
16091 | 906 |
fun to_isar_proof (frees, xs, goalstring) = |
907 |
let val extraaxioms = get_extraaxioms xs |
|
908 |
val extraax_num = length extraaxioms |
|
909 |
val origaxioms_and_steps = Library.drop (extraax_num, xs) |
|
910 |
||
911 |
val origaxioms = get_origaxioms origaxioms_and_steps |
|
912 |
val origax_num = length origaxioms |
|
913 |
val axioms_and_steps = Library.drop (origax_num + extraax_num, xs) |
|
914 |
val axioms = get_axioms axioms_and_steps |
|
915 |
||
916 |
val steps = Library.drop (origax_num, axioms_and_steps) |
|
917 |
val firststeps = ReconOrderClauses.butlast steps |
|
918 |
val laststep = ReconOrderClauses.last steps |
|
919 |
val goalstring = implode(ReconOrderClauses.butlast(explode goalstring)) |
|
920 |
||
921 |
val isar_proof = |
|
922 |
("show \""^goalstring^"\"\n")^ |
|
923 |
("proof (rule ccontr,skolemize, make_clauses) \n")^ |
|
924 |
("fix "^(frees_to_isar_str frees)^"\n")^ |
|
925 |
(assume_isar_extraaxioms extraaxioms)^ |
|
926 |
(assume_isar_origaxioms origaxioms)^ |
|
927 |
(isar_axiomlines axioms "")^ |
|
928 |
(isar_lines firststeps "")^ |
|
929 |
(last_isar_line laststep)^ |
|
930 |
("qed") |
|
16259 | 931 |
val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "isar_proof_file"))); |
16091 | 932 |
|
933 |
val _ = TextIO.output (outfile, isar_proof) |
|
934 |
val _ = TextIO.closeOut outfile |
|
935 |
in |
|
936 |
isar_proof |
|
937 |
end; |
|
15642 | 938 |
|
939 |
(* get fix vars from axioms - all Frees *) |
|
940 |
(* check each clause for meta-vars and /\ over them at each step*) |
|
941 |
||
942 |
(*******************************************************) |
|
943 |
(* This assumes the thm list "numcls" is still there *) |
|
944 |
(* In reality, should probably label it with an *) |
|
945 |
(* ID number identifying the subgoal. This could *) |
|
946 |
(* be passed over to the watcher, e.g. numcls25 *) |
|
947 |
(*******************************************************) |
|
948 |
||
949 |
(* 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))[][]"; |
|
950 |
||
951 |
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))[][]"; |
|
952 |
||
953 |
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)"; |
|
954 |
||
955 |
||
956 |
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))[][]"; |
|
957 |
||
958 |
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)))"; |
|
959 |
*) |
|
960 |
||
15739
bb2acfed8212
yet more tidying up: removal of some references to Main
paulson
parents:
15700
diff
changeset
|
961 |
fun apply_res_thm str goalstring = let val tokens = #1 (lex str); |
16357 | 962 |
val _ = File.append (File.tmp_path (Path.basic "applyres")) |
963 |
("str is: "^str^" goalstr is: "^goalstring^"\n") |
|
15642 | 964 |
val (frees,recon_steps) = parse_step tokens |
965 |
val isar_str = to_isar_proof (frees, recon_steps, goalstring) |
|
16259 | 966 |
val foo = TextIO.openOut (File.platform_path(File.tmp_path (Path.basic "foobar"))); |
15642 | 967 |
in |
968 |
TextIO.output(foo,(isar_str));TextIO.closeOut foo;Pretty.writeln(Pretty.str isar_str); () |
|
969 |
end |
|
970 |
||
971 |
||
16357 | 972 |
(* val reconstr = reconstr^"[P%]51Axiom()[~P%]52Axiom[P%][]53MRR((52,0),(51,0))[][]"; |
973 |
*) |
|
15684
5ec4d21889d6
Reconstruction code, now packaged to avoid name clashes
paulson
parents:
15658
diff
changeset
|
974 |
end; |