author | haftmann |
Mon, 16 Jul 2007 09:29:04 +0200 | |
changeset 23811 | b18557301bf9 |
parent 22194 | 3b1da1ff65df |
child 24195 | 7d1a16c77f7c |
permissions | -rw-r--r-- |
19208 | 1 |
(* Authors: Jia Meng, NICTA and Lawrence C Paulson, Cambridge University Computer Laboratory |
2 |
ID: $Id$ |
|
3 |
Filtering strategies *) |
|
4 |
||
20457
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
5 |
(*A surprising number of theorems contain only a few significant constants. |
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
6 |
These include all induction rules, and other general theorems. Filtering |
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
7 |
theorems in clause form reveals these complexities in the form of Skolem |
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
8 |
functions. If we were instead to filter theorems in their natural form, |
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
9 |
some other method of measuring theorem complexity would become necessary.*) |
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
10 |
|
18791 | 11 |
structure ReduceAxiomsN = |
12 |
struct |
|
13 |
||
20457
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
14 |
val run_relevance_filter = ref true; |
20825 | 15 |
val theory_const = ref true; |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
16 |
val pass_mark = ref 0.5; |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
17 |
val convergence = ref 3.2; (*Higher numbers allow longer inference chains*) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
18 |
val max_new = ref 60; (*Limits how many clauses can be picked up per stage*) |
20423 | 19 |
val follow_defs = ref false; (*Follow definitions. Makes problems bigger.*) |
18791 | 20 |
|
19337
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
21 |
fun log_weight2 (x:real) = 1.0 + 2.0/Math.ln (x+1.0); |
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
22 |
|
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
23 |
(*The default seems best in practice. A constant function of one ignores |
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
24 |
the constant frequencies.*) |
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
25 |
val weight_fn = ref log_weight2; |
19334
96ca738055a6
Simplified version of Jia's filter. Now all constants are pooled, rather than
paulson
parents:
19321
diff
changeset
|
26 |
|
18791 | 27 |
|
19231 | 28 |
(*Including equality in this list might be expected to stop rules like subset_antisym from |
20527
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
29 |
being chosen, but for some reason filtering works better with them listed. The |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
30 |
logical signs All, Ex, &, and --> are omitted because any remaining occurrrences |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
31 |
must be within comprehensions.*) |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
32 |
val standard_consts = ["Trueprop","==>","all","==","op |","Not","op ="]; |
18791 | 33 |
|
34 |
||
19009 | 35 |
(*** constants with types ***) |
36 |
||
19231 | 37 |
(*An abstraction of Isabelle types*) |
19009 | 38 |
datatype const_typ = CTVar | CType of string * const_typ list |
39 |
||
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
40 |
(*Is the second type an instance of the first one?*) |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
41 |
fun match_type (CType(con1,args1)) (CType(con2,args2)) = |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
42 |
con1=con2 andalso match_types args1 args2 |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
43 |
| match_type CTVar _ = true |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
44 |
| match_type _ CTVar = false |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
45 |
and match_types [] [] = true |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
46 |
| match_types (a1::as1) (a2::as2) = match_type a1 a2 andalso match_types as1 as2; |
19009 | 47 |
|
20132 | 48 |
(*Is there a unifiable constant?*) |
49 |
fun uni_mem gctab (c,c_typ) = |
|
50 |
case Symtab.lookup gctab c of |
|
51 |
NONE => false |
|
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
52 |
| SOME ctyps_list => exists (match_types c_typ) ctyps_list; |
20132 | 53 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
54 |
(*Maps a "real" type to a const_typ*) |
19231 | 55 |
fun const_typ_of (Type (c,typs)) = CType (c, map const_typ_of typs) |
56 |
| const_typ_of (TFree _) = CTVar |
|
57 |
| const_typ_of (TVar _) = CTVar |
|
19009 | 58 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
59 |
(*Pairs a constant with the list of its type instantiations (using const_typ)*) |
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
60 |
fun const_with_typ thy (c,typ) = |
19212 | 61 |
let val tvars = Sign.const_typargs thy (c,typ) |
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
62 |
in (c, map const_typ_of tvars) end |
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
63 |
handle TYPE _ => (c,[]); (*Variable (locale constant): monomorphic*) |
19009 | 64 |
|
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
65 |
(*Add a const/type pair to the table, but a [] entry means a standard connective, |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
66 |
which we ignore.*) |
20132 | 67 |
fun add_const_typ_table ((c,ctyps), tab) = |
20854 | 68 |
Symtab.map_default (c, [ctyps]) (fn [] => [] | ctyps_list => insert (op =) ctyps ctyps_list) |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
69 |
tab; |
20132 | 70 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
71 |
(*Free variables are included, as well as constants, to handle locales*) |
20132 | 72 |
fun add_term_consts_typs_rm thy (Const(c, typ), tab) = |
73 |
add_const_typ_table (const_with_typ thy (c,typ), tab) |
|
74 |
| add_term_consts_typs_rm thy (Free(c, typ), tab) = |
|
75 |
add_const_typ_table (const_with_typ thy (c,typ), tab) |
|
76 |
| add_term_consts_typs_rm thy (t $ u, tab) = |
|
77 |
add_term_consts_typs_rm thy (t, add_term_consts_typs_rm thy (u, tab)) |
|
78 |
| add_term_consts_typs_rm thy (Abs(_,_,t), tab) = add_term_consts_typs_rm thy (t, tab) |
|
79 |
| add_term_consts_typs_rm thy (_, tab) = tab; |
|
19009 | 80 |
|
20132 | 81 |
(*The empty list here indicates that the constant is being ignored*) |
82 |
fun add_standard_const (s,tab) = Symtab.update (s,[]) tab; |
|
19009 | 83 |
|
20132 | 84 |
val null_const_tab : const_typ list list Symtab.table = |
85 |
foldl add_standard_const Symtab.empty standard_consts; |
|
86 |
||
20457
85414caac94a
refinements to conversion into clause form, esp for the HO case
paulson
parents:
20423
diff
changeset
|
87 |
fun get_goal_consts_typs thy = foldl (add_term_consts_typs_rm thy) null_const_tab; |
19009 | 88 |
|
20527
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
89 |
(*Inserts a dummy "constant" referring to the theory name, so that relevance |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
90 |
takes the given theory into account.*) |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
91 |
fun const_prop_of th = |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
92 |
if !theory_const then |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
93 |
let val name = Context.theory_name (theory_of_thm th) |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
94 |
val t = Const (name ^ ". 1", HOLogic.boolT) |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
95 |
in t $ prop_of th end |
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
96 |
else prop_of th; |
19231 | 97 |
|
98 |
(**** Constant / Type Frequencies ****) |
|
99 |
||
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
100 |
(*A two-dimensional symbol table counts frequencies of constants. It's keyed first by |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
101 |
constant name and second by its list of type instantiations. For the latter, we need |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
102 |
a linear ordering on type const_typ list.*) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
103 |
|
19231 | 104 |
local |
105 |
||
106 |
fun cons_nr CTVar = 0 |
|
107 |
| cons_nr (CType _) = 1; |
|
108 |
||
109 |
in |
|
110 |
||
111 |
fun const_typ_ord TU = |
|
112 |
case TU of |
|
113 |
(CType (a, Ts), CType (b, Us)) => |
|
114 |
(case fast_string_ord(a,b) of EQUAL => dict_ord const_typ_ord (Ts,Us) | ord => ord) |
|
115 |
| (T, U) => int_ord (cons_nr T, cons_nr U); |
|
19212 | 116 |
|
19231 | 117 |
end; |
118 |
||
119 |
structure CTtab = TableFun(type key = const_typ list val ord = dict_ord const_typ_ord); |
|
19212 | 120 |
|
19355 | 121 |
fun count_axiom_consts thy ((thm,_), tab) = |
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
122 |
let fun count_const (a, T, tab) = |
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
123 |
let val (c, cts) = const_with_typ thy (a,T) |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
124 |
in (*Two-dimensional table update. Constant maps to types maps to count.*) |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
125 |
Symtab.map_default (c, CTtab.empty) |
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
126 |
(CTtab.map_default (cts,0) (fn n => n+1)) tab |
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
127 |
end |
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
128 |
fun count_term_consts (Const(a,T), tab) = count_const(a,T,tab) |
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
129 |
| count_term_consts (Free(a,T), tab) = count_const(a,T,tab) |
19231 | 130 |
| count_term_consts (t $ u, tab) = |
131 |
count_term_consts (t, count_term_consts (u, tab)) |
|
132 |
| count_term_consts (Abs(_,_,t), tab) = count_term_consts (t, tab) |
|
133 |
| count_term_consts (_, tab) = tab |
|
20527
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
134 |
in count_term_consts (const_prop_of thm, tab) end; |
19212 | 135 |
|
19009 | 136 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
137 |
(**** Actual Filtering Code ****) |
19009 | 138 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
139 |
(*The frequency of a constant is the sum of those of all instances of its type.*) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
140 |
fun const_frequency ctab (c, cts) = |
19231 | 141 |
let val pairs = CTtab.dest (Option.valOf (Symtab.lookup ctab c)) |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
142 |
fun add ((cts',m), n) = if match_types cts cts' then m+n else n |
19231 | 143 |
in List.foldl add 0 pairs end; |
144 |
||
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
145 |
(*Add in a constant's weight, as determined by its frequency.*) |
19231 | 146 |
fun add_ct_weight ctab ((c,T), w) = |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
147 |
w + !weight_fn (real (const_frequency ctab (c,T))); |
19212 | 148 |
|
19231 | 149 |
(*Relevant constants are weighted according to frequency, |
150 |
but irrelevant constants are simply counted. Otherwise, Skolem functions, |
|
151 |
which are rare, would harm a clause's chances of being picked.*) |
|
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
152 |
fun clause_weight ctab gctyps consts_typs = |
20132 | 153 |
let val rel = filter (uni_mem gctyps) consts_typs |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
154 |
val rel_weight = List.foldl (add_ct_weight ctab) 0.0 rel |
19009 | 155 |
in |
19231 | 156 |
rel_weight / (rel_weight + real (length consts_typs - length rel)) |
19009 | 157 |
end; |
19315
b218cc3d1bb4
Removal of obsolete strategies. Initial support for locales: Frees and Consts
paulson
parents:
19231
diff
changeset
|
158 |
|
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
159 |
(*Multiplies out to a list of pairs: 'a * 'b list -> ('a * 'b) list -> ('a * 'b) list*) |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
160 |
fun add_expand_pairs (x,ys) xys = foldl (fn (y,acc) => (x,y)::acc) xys ys; |
20132 | 161 |
|
162 |
fun consts_typs_of_term thy t = |
|
163 |
let val tab = add_term_consts_typs_rm thy (t, null_const_tab) |
|
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
164 |
in Symtab.fold add_expand_pairs tab [] end; |
20132 | 165 |
|
19355 | 166 |
fun pair_consts_typs_axiom thy (thm,name) = |
20527
958ec4833d87
Added the "theory_const" option. Only it is OFF because it's often harmful!
paulson
parents:
20457
diff
changeset
|
167 |
((thm,name), (consts_typs_of_term thy (const_prop_of thm))); |
19009 | 168 |
|
19321 | 169 |
exception ConstFree; |
170 |
fun dest_ConstFree (Const aT) = aT |
|
171 |
| dest_ConstFree (Free aT) = aT |
|
172 |
| dest_ConstFree _ = raise ConstFree; |
|
173 |
||
174 |
(*Look for definitions of the form f ?x1 ... ?xn = t, but not reversed.*) |
|
19355 | 175 |
fun defines thy (thm,(name,n)) gctypes = |
176 |
let val tm = prop_of thm |
|
19448 | 177 |
fun defs lhs rhs = |
178 |
let val (rator,args) = strip_comb lhs |
|
19355 | 179 |
val ct = const_with_typ thy (dest_ConstFree rator) |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
180 |
in forall is_Var args andalso uni_mem gctypes ct andalso |
20197
ffc64d90fc1f
use Term.add_vars instead of obsolete term_varnames;
wenzelm
parents:
20153
diff
changeset
|
181 |
Term.add_vars rhs [] subset Term.add_vars lhs [] |
19448 | 182 |
end |
183 |
handle ConstFree => false |
|
19355 | 184 |
in |
19448 | 185 |
case tm of Const ("Trueprop",_) $ (Const("op =",_) $ lhs $ rhs) => |
186 |
defs lhs rhs andalso |
|
22130 | 187 |
(Output.debug (fn () => "Definition found: " ^ name ^ "_" ^ Int.toString n); true) |
19355 | 188 |
| _ => false |
20132 | 189 |
end; |
19321 | 190 |
|
21677 | 191 |
type annotd_cls = (thm * (string * int)) * ((string * const_typ list) list); |
192 |
||
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
193 |
(*For a reverse sort, putting the largest values first.*) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
194 |
fun compare_pairs ((_,w1),(_,w2)) = Real.compare (w2,w1); |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
195 |
|
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
196 |
(*Limit the number of new clauses, to prevent runaway acceptance.*) |
21677 | 197 |
fun take_best (newpairs : (annotd_cls*real) list) = |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
198 |
let val nnew = length newpairs |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
199 |
in |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
200 |
if nnew <= !max_new then (map #1 newpairs, []) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
201 |
else |
21677 | 202 |
let val cls = sort compare_pairs newpairs |
203 |
val accepted = List.take (cls, !max_new) |
|
22130 | 204 |
in |
205 |
Output.debug (fn () => ("Number of candidates, " ^ Int.toString nnew ^ |
|
206 |
", exceeds the limit of " ^ Int.toString (!max_new))); |
|
207 |
Output.debug (fn () => ("Effective pass mark: " ^ Real.toString (#2 (List.last accepted)))); |
|
208 |
Output.debug (fn () => "Actually passed: " ^ |
|
209 |
space_implode ", " (map (fn (((_,(name,_)),_),_) => name) accepted)); |
|
210 |
||
211 |
(map #1 accepted, map #1 (List.drop (cls, !max_new))) |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
212 |
end |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
213 |
end; |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
214 |
|
19337
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
215 |
fun relevant_clauses thy ctab p rel_consts = |
21677 | 216 |
let fun relevant ([],_) [] = [] : (thm * (string * int)) list (*Nothing added this iteration*) |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
217 |
| relevant (newpairs,rejects) [] = |
21677 | 218 |
let val (newrels,more_rejects) = take_best newpairs |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
219 |
val new_consts = List.concat (map #2 newrels) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
220 |
val rel_consts' = foldl add_const_typ_table rel_consts new_consts |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
221 |
val newp = p + (1.0-p) / !convergence |
22130 | 222 |
in |
223 |
Output.debug (fn () => ("relevant this iteration: " ^ Int.toString (length newrels))); |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
224 |
(map #1 newrels) @ |
21677 | 225 |
(relevant_clauses thy ctab newp rel_consts' (more_rejects@rejects)) |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
226 |
end |
20153
6ff5d35749b0
Fixed the bugs introduced by the last commit! Output is now *identical* to that
paulson
parents:
20132
diff
changeset
|
227 |
| relevant (newrels,rejects) ((ax as (clsthm as (_,(name,n)),consts_typs)) :: axs) = |
19337
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
228 |
let val weight = clause_weight ctab rel_consts consts_typs |
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
229 |
in |
19355 | 230 |
if p <= weight orelse (!follow_defs andalso defines thy clsthm rel_consts) |
22194 | 231 |
then (Output.debug (fn () => (name ^ " clause " ^ Int.toString n ^ |
232 |
" passes: " ^ Real.toString weight)); |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
233 |
relevant ((ax,weight)::newrels, rejects) axs) |
19337
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
234 |
else relevant (newrels, ax::rejects) axs |
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
235 |
end |
22130 | 236 |
in Output.debug (fn () => ("relevant_clauses, current pass mark = " ^ Real.toString p)); |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
237 |
relevant ([],[]) |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
238 |
end; |
19337
146b25b893bb
pool of constants; definition expansion; current best settings
paulson
parents:
19335
diff
changeset
|
239 |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
240 |
fun relevance_filter thy axioms goals = |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
241 |
if !run_relevance_filter andalso !pass_mark >= 0.1 |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
242 |
then |
22130 | 243 |
let val _ = Output.debug (fn () => "Start of relevance filtering"); |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
244 |
val const_tab = List.foldl (count_axiom_consts thy) Symtab.empty axioms |
21677 | 245 |
val goal_const_tab = get_goal_consts_typs thy goals |
22130 | 246 |
val _ = Output.debug (fn () => ("Initial constants: " ^ |
247 |
space_implode ", " (Symtab.keys goal_const_tab))); |
|
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
248 |
val rels = relevant_clauses thy const_tab (!pass_mark) |
21677 | 249 |
goal_const_tab (map (pair_consts_typs_axiom thy) axioms) |
19231 | 250 |
in |
22130 | 251 |
Output.debug (fn () => ("Total relevant: " ^ Int.toString (length rels))); |
19334
96ca738055a6
Simplified version of Jia's filter. Now all constants are pooled, rather than
paulson
parents:
19321
diff
changeset
|
252 |
rels |
20566
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
253 |
end |
499500b1e348
Added the max_new parameter, which is a cap on how many clauses may be admitted per round.
paulson
parents:
20527
diff
changeset
|
254 |
else axioms; |
18791 | 255 |
|
20197
ffc64d90fc1f
use Term.add_vars instead of obsolete term_varnames;
wenzelm
parents:
20153
diff
changeset
|
256 |
end; |