author | paulson |
Thu, 07 Jul 2005 18:25:02 +0200 | |
changeset 16741 | 7a6c17b826c0 |
parent 16357 | f1275d2a1dee |
child 16795 | b400b53d8f7d |
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 |
|
16741
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
8 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
9 |
structure ReduceAxiomsN = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
10 |
(* Author: Jia Meng, Cambridge University Computer Laboratory |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
11 |
Remove irrelevant axioms used for a proof of a goal, with with iteration control*) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
12 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
13 |
struct |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
14 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
15 |
fun add_term_consts_rm ncs (Const(c, _)) cs = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
16 |
if (c mem ncs) then cs else (c ins_string cs) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
17 |
| add_term_consts_rm ncs (t $ u) cs = add_term_consts_rm ncs t (add_term_consts_rm ncs u cs) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
18 |
| add_term_consts_rm ncs (Abs(_,_,t)) cs = add_term_consts_rm ncs t cs |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
19 |
| add_term_consts_rm ncs _ cs = cs; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
20 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
21 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
22 |
fun term_consts_rm ncs t = add_term_consts_rm ncs t []; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
23 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
24 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
25 |
fun thm_consts_rm ncs thm = term_consts_rm ncs (prop_of thm); |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
26 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
27 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
28 |
fun consts_of_thm (n,thm) = thm_consts_rm ["Trueprop","==>","all","Ex","op &", "op |", "Not", "All", "op -->", "op =", "==", "True", "False"] thm; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
29 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
30 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
31 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
32 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
33 |
fun consts_of_term term = term_consts_rm ["Trueprop","==>","all","Ex","op &", "op |", "Not", "All", "op -->", "op =", "==", "True", "False"] term; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
34 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
35 |
fun make_pairs [] _ = [] |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
36 |
| make_pairs (x::xs) y = (x,y)::(make_pairs xs y); |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
37 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
38 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
39 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
40 |
fun const_thm_list_aux [] cthms = cthms |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
41 |
| const_thm_list_aux (thm::thms) cthms = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
42 |
let val consts = consts_of_thm thm |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
43 |
val cthms' = make_pairs consts thm |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
44 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
45 |
const_thm_list_aux thms (cthms' @ cthms) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
46 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
47 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
48 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
49 |
fun const_thm_list thms = const_thm_list_aux thms []; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
50 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
51 |
fun make_thm_table thms = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
52 |
let val consts_thms = const_thm_list thms |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
53 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
54 |
Symtab.make_multi consts_thms |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
55 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
56 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
57 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
58 |
fun consts_in_goal goal = consts_of_term goal; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
59 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
60 |
fun axioms_having_consts_aux [] tab thms = thms |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
61 |
| axioms_having_consts_aux (c::cs) tab thms = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
62 |
let val thms1 = Symtab.lookup(tab,c) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
63 |
val thms2 = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
64 |
case thms1 of (SOME x) => x |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
65 |
| NONE => [] |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
66 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
67 |
axioms_having_consts_aux cs tab (thms2 union thms) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
68 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
69 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
70 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
71 |
fun axioms_having_consts cs tab = axioms_having_consts_aux cs tab []; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
72 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
73 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
74 |
fun relevant_axioms goal thmTab n = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
75 |
let val consts = consts_in_goal goal |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
76 |
fun relevant_axioms_aux1 cs k = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
77 |
let val thms1 = axioms_having_consts cs thmTab |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
78 |
val cs1 = ResLib.flat_noDup (map consts_of_thm thms1) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
79 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
80 |
if ((cs1 subset cs) orelse (n <= k)) then (k,thms1) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
81 |
else (relevant_axioms_aux1 (cs1 union cs) (k+1)) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
82 |
end |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
83 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
84 |
fun relevant_axioms_aux2 cs k = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
85 |
let val thms1 = axioms_having_consts cs thmTab |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
86 |
val cs1 = ResLib.flat_noDup (map consts_of_thm thms1) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
87 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
88 |
if (cs1 subset cs) then (k,thms1) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
89 |
else (relevant_axioms_aux2 (cs1 union cs) (k+1)) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
90 |
end |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
91 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
92 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
93 |
if n <= 0 then (relevant_axioms_aux2 consts 1) else (relevant_axioms_aux1 consts 1) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
94 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
95 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
96 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
97 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
98 |
fun relevant_filter n goal thms = #2 (relevant_axioms goal (make_thm_table thms) n); |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
99 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
100 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
101 |
(* find the thms from thy that contain relevant constants, n is the iteration number *) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
102 |
fun find_axioms_n thy goal n = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
103 |
let val clasetR = ResAxioms.claset_rules_of_thy thy |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
104 |
val simpsetR = ResAxioms.simpset_rules_of_thy thy |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
105 |
val table = make_thm_table (clasetR @ simpsetR) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
106 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
107 |
relevant_axioms goal table n |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
108 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
109 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
110 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
111 |
fun find_axioms_n_c thy goal n = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
112 |
let val current_thms = PureThy.thms_of thy |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
113 |
val table = make_thm_table current_thms |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
114 |
in |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
115 |
relevant_axioms goal table n |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
116 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
117 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
118 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
119 |
end; |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
120 |
|
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
121 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
122 |
signature RES_CLASIMP = |
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
123 |
sig |
16741
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
124 |
val write_out_clasimp : string -> theory -> term -> |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
125 |
(ResClause.clause * thm) Array.array * int |
16357 | 126 |
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
|
127 |
end; |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
128 |
|
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
129 |
structure ResClasimp : RES_CLASIMP = |
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
130 |
struct |
15643 | 131 |
|
16061 | 132 |
fun has_name th = ((Thm.name_of_thm th) <> "") |
133 |
||
134 |
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
|
135 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
136 |
|
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
137 |
(* 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
|
138 |
(* 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
|
139 |
|
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
140 |
(* outputs a list of (thm,clause) pairs *) |
15643 | 141 |
|
142 |
||
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
143 |
(* 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
|
144 |
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
|
145 |
| 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
|
146 |
| 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
|
147 |
|
16061 | 148 |
fun remove_symb str = |
149 |
if String.isPrefix "List.op @." str |
|
150 |
then ((String.substring(str,0,5)) ^ (String.extract (str, 10, NONE))) |
|
151 |
else str; |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
152 |
|
16061 | 153 |
fun remove_spaces str = |
154 |
let val strlist = String.tokens Char.isSpace str |
|
155 |
val spaceless = concat strlist |
|
156 |
val strlist' = String.tokens Char.isPunct spaceless |
|
157 |
in |
|
158 |
concat_with_stop strlist' |
|
159 |
end |
|
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
160 |
|
16061 | 161 |
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
|
162 |
|
16061 | 163 |
fun remove_spaces_pair (str, thm) = (remove_spaces str, thm); |
15643 | 164 |
|
15956 | 165 |
|
166 |
(*Insert th into the result provided the name is not "".*) |
|
167 |
fun add_nonempty ((name,th), ths) = if name="" then ths else th::ths; |
|
168 |
||
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
169 |
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
|
170 |
| 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
|
171 |
then |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
172 |
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
|
173 |
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
|
174 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
175 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
176 |
fun pairup [] [] = [] |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
177 |
| 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
|
178 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
179 |
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
|
180 |
|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
|
181 |
|
16172
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
182 |
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
in |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
187 |
(multi_name) |
629ba53a072f
small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents:
16156
diff
changeset
|
188 |
end; |
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
189 |
|
16741
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
190 |
(*Write out the claset and simpset rules of the supplied theory. |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
191 |
FIXME: argument "goal" is a hack to allow relevance filtering.*) |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
192 |
fun write_out_clasimp filename thy goal = |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
193 |
let val claset_rules = ReduceAxiomsN.relevant_filter 1 goal |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
194 |
(ResAxioms.claset_rules_of_thy thy); |
16061 | 195 |
val named_claset = List.filter has_name_pair claset_rules; |
196 |
val claset_names = map remove_spaces_pair (named_claset) |
|
197 |
val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_claset []); |
|
15643 | 198 |
|
16741
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
199 |
val simpset_rules = ReduceAxiomsN.relevant_filter 1 goal |
7a6c17b826c0
inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents:
16357
diff
changeset
|
200 |
(ResAxioms.simpset_rules_of_thy thy); |
16061 | 201 |
val named_simpset = |
202 |
map remove_spaces_pair (List.filter has_name_pair simpset_rules) |
|
203 |
val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []); |
|
15643 | 204 |
|
16061 | 205 |
val cls_thms = (claset_cls_thms@simpset_cls_thms); |
206 |
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
|
207 |
(* length 1429 *) |
16061 | 208 |
(*************************************************) |
209 |
(* Write out clauses as tptp strings to filename *) |
|
210 |
(*************************************************) |
|
211 |
val clauses = map #1(cls_thms_list); |
|
212 |
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
|
213 |
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
|
214 |
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
|
215 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
216 |
(*********************************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
217 |
(* 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
|
218 |
(*********************************************************) |
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
|
16061 | 223 |
(* list of lists of tptp string clauses *) |
224 |
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
|
225 |
(* length 1581*) |
16061 | 226 |
val out = TextIO.openOut filename; |
227 |
val _= ResLib.writeln_strs out stick_clasrls; |
|
228 |
val _= TextIO.flushOut out; |
|
229 |
val _= TextIO.closeOut out |
|
230 |
in |
|
231 |
(clause_arr, num_of_clauses) |
|
232 |
end; |
|
15643 | 233 |
|
16357 | 234 |
|
235 |
||
236 |
||
237 |
||
238 |
(*Write out the claset and simpset rules of the supplied theory. Only include the first 50 rules*) |
|
239 |
fun write_out_clasimp_small filename thy = |
|
240 |
let val claset_rules = ResAxioms.claset_rules_of_thy thy; |
|
241 |
val named_claset = List.filter has_name_pair claset_rules; |
|
242 |
val claset_names = map remove_spaces_pair (named_claset) |
|
243 |
val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_claset []); |
|
244 |
||
245 |
val simpset_rules = ResAxioms.simpset_rules_of_thy thy; |
|
246 |
val named_simpset = |
|
247 |
map remove_spaces_pair (List.filter has_name_pair simpset_rules) |
|
248 |
val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []); |
|
249 |
||
250 |
val cls_thms = (claset_cls_thms@simpset_cls_thms); |
|
251 |
val cls_thms_list = List.concat cls_thms; |
|
252 |
(* length 1429 *) |
|
253 |
(*************************************************) |
|
254 |
(* Write out clauses as tptp strings to filename *) |
|
255 |
(*************************************************) |
|
256 |
val clauses = map #1(cls_thms_list); |
|
257 |
val cls_tptp_strs = map ResClause.tptp_clause clauses; |
|
258 |
val alllist = pairup cls_thms_list cls_tptp_strs |
|
259 |
val whole_list = List.concat (map clause_numbering alllist); |
|
260 |
val mini_list = List.take ( whole_list,50) |
|
261 |
(*********************************************************) |
|
262 |
(* create array and put clausename, number pairs into it *) |
|
263 |
(*********************************************************) |
|
264 |
val num_of_clauses = 0; |
|
265 |
val clause_arr = Array.fromList mini_list; |
|
266 |
val num_of_clauses = List.length mini_list; |
|
267 |
||
268 |
(* list of lists of tptp string clauses *) |
|
269 |
val stick_clasrls = List.concat cls_tptp_strs; |
|
270 |
(* length 1581*) |
|
271 |
val out = TextIO.openOut filename; |
|
272 |
val _= ResLib.writeln_strs out (List.take (stick_clasrls,50)); |
|
273 |
val _= TextIO.flushOut out; |
|
274 |
val _= TextIO.closeOut out |
|
275 |
in |
|
276 |
(clause_arr, num_of_clauses) |
|
277 |
end; |
|
278 |
||
279 |
||
280 |
||
15919
b30a35432f5a
Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents:
15907
diff
changeset
|
281 |
end; |
16039
dfe264950511
Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents:
15956
diff
changeset
|
282 |
|
16156
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
283 |
|
2f6fc19aba1e
Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents:
16061
diff
changeset
|
284 |