author | quigley |
Tue, 31 May 2005 12:42:36 +0200 | |
changeset 16156 | 2f6fc19aba1e |
parent 16061 | 8a139c1557bf |
child 16172 | 629ba53a072f |
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 |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
10 |
val write_out_clasimp :string -> (ResClause.clause * Thm.thm) Array.array * int |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
11 |
end; |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
12 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
13 |
structure ResClasimp : RES_CLASIMP = |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
14 |
struct |
15643 | 15 |
|
16061 | 16 |
fun has_name th = ((Thm.name_of_thm th) <> "") |
17 |
||
18 |
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
|
19 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
20 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
21 |
(* 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
|
22 |
(* 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
|
23 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
24 |
(* outputs a list of (thm,clause) pairs *) |
15643 | 25 |
|
26 |
||
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
27 |
(* 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
|
28 |
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
|
29 |
| 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
|
30 |
| 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
|
31 |
|
16061 | 32 |
fun remove_symb str = |
33 |
if String.isPrefix "List.op @." str |
|
34 |
then ((String.substring(str,0,5)) ^ (String.extract (str, 10, NONE))) |
|
35 |
else str; |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
36 |
|
16061 | 37 |
fun remove_spaces str = |
38 |
let val strlist = String.tokens Char.isSpace str |
|
39 |
val spaceless = concat strlist |
|
40 |
val strlist' = String.tokens Char.isPunct spaceless |
|
41 |
in |
|
42 |
concat_with_stop strlist' |
|
43 |
end |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
44 |
|
16061 | 45 |
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
|
46 |
|
16061 | 47 |
fun remove_spaces_pair (str, thm) = (remove_spaces str, thm); |
15643 | 48 |
|
15956 | 49 |
|
50 |
(*Insert th into the result provided the name is not "".*) |
|
51 |
fun add_nonempty ((name,th), ths) = if name="" then ths else th::ths; |
|
52 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
53 |
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
|
54 |
| 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
|
55 |
then |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
|
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 |
fun pairup [] [] = [] |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
61 |
| 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
|
62 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
63 |
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
|
64 |
|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
|
65 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
66 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
67 |
fun clause_numbering ((clause, theorem), cls) = let val num_of_cls = length cls |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
68 |
val numbers = 0 upto (num_of_cls -1) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
69 |
val multi_name = multi (clause, theorem) num_of_cls [] |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
70 |
in |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
71 |
(multi_name) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
72 |
end; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
73 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
74 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
75 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
76 |
|
15956 | 77 |
|
16061 | 78 |
fun write_out_clasimp filename = |
79 |
let val claset_rules = ResAxioms.claset_rules_of_thy (the_context()); |
|
80 |
val named_claset = List.filter has_name_pair claset_rules; |
|
81 |
val claset_names = map remove_spaces_pair (named_claset) |
|
82 |
val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_claset []); |
|
15643 | 83 |
|
16061 | 84 |
val simpset_rules = ResAxioms.simpset_rules_of_thy (the_context()); |
85 |
val named_simpset = |
|
86 |
map remove_spaces_pair (List.filter has_name_pair simpset_rules) |
|
87 |
val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []); |
|
15643 | 88 |
|
16061 | 89 |
val cls_thms = (claset_cls_thms@simpset_cls_thms); |
90 |
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
|
91 |
(* length 1429 *) |
16061 | 92 |
(*************************************************) |
93 |
(* Write out clauses as tptp strings to filename *) |
|
94 |
(*************************************************) |
|
95 |
val clauses = map #1(cls_thms_list); |
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
|
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 |
(* 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
|
102 |
(*********************************************************) |
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 = 0; |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
|
16061 | 107 |
(* list of lists of tptp string clauses *) |
108 |
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
|
109 |
(* length 1581*) |
16061 | 110 |
val out = TextIO.openOut filename; |
111 |
val _= ResLib.writeln_strs out stick_clasrls; |
|
112 |
val _= TextIO.flushOut out; |
|
113 |
val _= TextIO.closeOut out |
|
114 |
in |
|
115 |
(clause_arr, num_of_clauses) |
|
116 |
end; |
|
15643 | 117 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
118 |
end; |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
119 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
120 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
121 |