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