author | quigley |
Fri, 10 Jun 2005 16:15:36 +0200 | |
changeset 16357 | f1275d2a1dee |
parent 16172 | 629ba53a072f |
child 16741 | 7a6c17b826c0 |
permissions | -rw-r--r-- |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
1 |
|
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15782
diff
changeset
|
2 |
(* ID: $Id$ |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
3 |
|
15789
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15782
diff
changeset
|
4 |
Author: Claire Quigley |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15782
diff
changeset
|
5 |
Copyright 2004 University of Cambridge |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15782
diff
changeset
|
6 |
*) |
4cb16144c81b
added hearder lines and deleted some redundant material
paulson
parents:
15782
diff
changeset
|
7 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
8 |
signature RES_CLASIMP = |
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
9 |
sig |
16172
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
10 |
val write_out_clasimp :string -> theory -> (ResClause.clause * thm) Array.array * int |
16357 | 11 |
val write_out_clasimp_small :string -> theory -> (ResClause.clause * thm) Array.array * int |
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
12 |
end; |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
13 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
14 |
structure ResClasimp : RES_CLASIMP = |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
15 |
struct |
15643 | 16 |
|
16061 | 17 |
fun has_name th = ((Thm.name_of_thm th) <> "") |
18 |
||
19 |
fun has_name_pair (a,b) = (a <> ""); |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
20 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
21 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
22 |
(* changed, now it also finds out the name of the theorem. *) |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
23 |
(* convert a theorem into CNF and then into Clause.clause format. *) |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
24 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
25 |
(* outputs a list of (thm,clause) pairs *) |
15643 | 26 |
|
27 |
||
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
28 |
(* for tracing: encloses each string element in brackets. *) |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
29 |
fun concat_with_stop [] = "" |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
30 |
| concat_with_stop [x] = x |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
31 |
| concat_with_stop (x::xs) = x^ "." ^ concat_with_stop xs; |
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
32 |
|
16061 | 33 |
fun remove_symb str = |
34 |
if String.isPrefix "List.op @." str |
|
35 |
then ((String.substring(str,0,5)) ^ (String.extract (str, 10, NONE))) |
|
36 |
else str; |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
37 |
|
16061 | 38 |
fun remove_spaces str = |
39 |
let val strlist = String.tokens Char.isSpace str |
|
40 |
val spaceless = concat strlist |
|
41 |
val strlist' = String.tokens Char.isPunct spaceless |
|
42 |
in |
|
43 |
concat_with_stop strlist' |
|
44 |
end |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
45 |
|
16061 | 46 |
fun remove_symb_pair (str, thm) = (remove_symb str, thm); |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
47 |
|
16061 | 48 |
fun remove_spaces_pair (str, thm) = (remove_spaces str, thm); |
15643 | 49 |
|
15956 | 50 |
|
51 |
(*Insert th into the result provided the name is not "".*) |
|
52 |
fun add_nonempty ((name,th), ths) = if name="" then ths else th::ths; |
|
53 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
54 |
fun posinlist x [] n = "not in list" |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
55 |
| posinlist x (y::ys) n = if (x=y) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
56 |
then |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
57 |
string_of_int n |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
58 |
else posinlist x (ys) (n+1) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
59 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
60 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
61 |
fun pairup [] [] = [] |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
62 |
| pairup (x::xs) (y::ys) = (x,y)::(pairup xs ys) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
63 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
64 |
fun multi x 0 xlist = xlist |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
65 |
|multi x n xlist = multi x (n -1 ) (x::xlist); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
66 |
|
16172
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
67 |
fun clause_numbering ((clause, theorem), cls) = |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
68 |
let val num_of_cls = length cls |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
69 |
val numbers = 0 upto (num_of_cls -1) |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
70 |
val multi_name = multi (clause, theorem) num_of_cls [] |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
71 |
in |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
72 |
(multi_name) |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
73 |
end; |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
74 |
|
16172
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
75 |
(*Write out the claset and simpset rules of the supplied theory.*) |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
76 |
fun write_out_clasimp filename thy = |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
77 |
let val claset_rules = ResAxioms.claset_rules_of_thy thy; |
16061 | 78 |
val named_claset = List.filter has_name_pair claset_rules; |
79 |
val claset_names = map remove_spaces_pair (named_claset) |
|
80 |
val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_claset []); |
|
15643 | 81 |
|
16172
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
82 |
val simpset_rules = ResAxioms.simpset_rules_of_thy thy; |
16061 | 83 |
val named_simpset = |
84 |
map remove_spaces_pair (List.filter has_name_pair simpset_rules) |
|
85 |
val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []); |
|
15643 | 86 |
|
16061 | 87 |
val cls_thms = (claset_cls_thms@simpset_cls_thms); |
88 |
val cls_thms_list = List.concat cls_thms; |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
89 |
(* length 1429 *) |
16061 | 90 |
(*************************************************) |
91 |
(* Write out clauses as tptp strings to filename *) |
|
92 |
(*************************************************) |
|
93 |
val clauses = map #1(cls_thms_list); |
|
94 |
val cls_tptp_strs = map ResClause.tptp_clause clauses; |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
95 |
val alllist = pairup cls_thms_list cls_tptp_strs |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
96 |
val whole_list = List.concat (map clause_numbering alllist); |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
97 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
98 |
(*********************************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
99 |
(* create array and put clausename, number pairs into it *) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
100 |
(*********************************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
101 |
val num_of_clauses = 0; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
102 |
val clause_arr = Array.fromList whole_list; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
103 |
val num_of_clauses = List.length whole_list; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
104 |
|
16061 | 105 |
(* list of lists of tptp string clauses *) |
106 |
val stick_clasrls = List.concat cls_tptp_strs; |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
107 |
(* length 1581*) |
16061 | 108 |
val out = TextIO.openOut filename; |
109 |
val _= ResLib.writeln_strs out stick_clasrls; |
|
110 |
val _= TextIO.flushOut out; |
|
111 |
val _= TextIO.closeOut out |
|
112 |
in |
|
113 |
(clause_arr, num_of_clauses) |
|
114 |
end; |
|
15643 | 115 |
|
16357 | 116 |
|
117 |
||
118 |
||
119 |
||
120 |
(*Write out the claset and simpset rules of the supplied theory. Only include the first 50 rules*) |
|
121 |
fun write_out_clasimp_small filename thy = |
|
122 |
let val claset_rules = ResAxioms.claset_rules_of_thy thy; |
|
123 |
val named_claset = List.filter has_name_pair claset_rules; |
|
124 |
val claset_names = map remove_spaces_pair (named_claset) |
|
125 |
val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_claset []); |
|
126 |
||
127 |
val simpset_rules = ResAxioms.simpset_rules_of_thy thy; |
|
128 |
val named_simpset = |
|
129 |
map remove_spaces_pair (List.filter has_name_pair simpset_rules) |
|
130 |
val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []); |
|
131 |
||
132 |
val cls_thms = (claset_cls_thms@simpset_cls_thms); |
|
133 |
val cls_thms_list = List.concat cls_thms; |
|
134 |
(* length 1429 *) |
|
135 |
(*************************************************) |
|
136 |
(* Write out clauses as tptp strings to filename *) |
|
137 |
(*************************************************) |
|
138 |
val clauses = map #1(cls_thms_list); |
|
139 |
val cls_tptp_strs = map ResClause.tptp_clause clauses; |
|
140 |
val alllist = pairup cls_thms_list cls_tptp_strs |
|
141 |
val whole_list = List.concat (map clause_numbering alllist); |
|
142 |
val mini_list = List.take ( whole_list,50) |
|
143 |
(*********************************************************) |
|
144 |
(* create array and put clausename, number pairs into it *) |
|
145 |
(*********************************************************) |
|
146 |
val num_of_clauses = 0; |
|
147 |
val clause_arr = Array.fromList mini_list; |
|
148 |
val num_of_clauses = List.length mini_list; |
|
149 |
||
150 |
(* list of lists of tptp string clauses *) |
|
151 |
val stick_clasrls = List.concat cls_tptp_strs; |
|
152 |
(* length 1581*) |
|
153 |
val out = TextIO.openOut filename; |
|
154 |
val _= ResLib.writeln_strs out (List.take (stick_clasrls,50)); |
|
155 |
val _= TextIO.flushOut out; |
|
156 |
val _= TextIO.closeOut out |
|
157 |
in |
|
158 |
(clause_arr, num_of_clauses) |
|
159 |
end; |
|
160 |
||
161 |
||
162 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
163 |
end; |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
164 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
165 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
166 |