clasohm@0
|
1 |
(* Title: Provers/classical
|
clasohm@0
|
2 |
ID: $Id$
|
clasohm@0
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
clasohm@0
|
4 |
Copyright 1992 University of Cambridge
|
clasohm@0
|
5 |
|
clasohm@0
|
6 |
Theorem prover for classical reasoning, including predicate calculus, set
|
clasohm@0
|
7 |
theory, etc.
|
clasohm@0
|
8 |
|
clasohm@0
|
9 |
Rules must be classified as intr, elim, safe, hazardous.
|
clasohm@0
|
10 |
|
clasohm@0
|
11 |
A rule is unsafe unless it can be applied blindly without harmful results.
|
clasohm@0
|
12 |
For a rule to be safe, its premises and conclusion should be logically
|
clasohm@0
|
13 |
equivalent. There should be no variables in the premises that are not in
|
clasohm@0
|
14 |
the conclusion.
|
clasohm@0
|
15 |
*)
|
clasohm@0
|
16 |
|
paulson@2868
|
17 |
(*Should be a type abbreviation in signature CLASSICAL*)
|
paulson@2868
|
18 |
type netpair = (int*(bool*thm)) Net.net * (int*(bool*thm)) Net.net;
|
paulson@2868
|
19 |
|
clasohm@0
|
20 |
signature CLASSICAL_DATA =
|
clasohm@0
|
21 |
sig
|
lcp@681
|
22 |
val mp : thm (* [| P-->Q; P |] ==> Q *)
|
lcp@681
|
23 |
val not_elim : thm (* [| ~P; P |] ==> R *)
|
lcp@681
|
24 |
val classical : thm (* (~P ==> P) ==> P *)
|
lcp@681
|
25 |
val sizef : thm -> int (* size function for BEST_FIRST *)
|
clasohm@0
|
26 |
val hyp_subst_tacs: (int -> tactic) list
|
clasohm@0
|
27 |
end;
|
clasohm@0
|
28 |
|
clasohm@0
|
29 |
(*Higher precedence than := facilitates use of references*)
|
paulson@1800
|
30 |
infix 4 addSIs addSEs addSDs addIs addEs addDs delrules
|
oheimb@2630
|
31 |
setSWrapper compSWrapper setWrapper compWrapper
|
oheimb@2630
|
32 |
addSbefore addSaltern addbefore addaltern;
|
clasohm@0
|
33 |
|
clasohm@0
|
34 |
|
clasohm@0
|
35 |
signature CLASSICAL =
|
clasohm@0
|
36 |
sig
|
clasohm@0
|
37 |
type claset
|
lcp@681
|
38 |
val empty_cs : claset
|
paulson@1711
|
39 |
val merge_cs : claset * claset -> claset
|
lcp@681
|
40 |
val addDs : claset * thm list -> claset
|
lcp@681
|
41 |
val addEs : claset * thm list -> claset
|
lcp@681
|
42 |
val addIs : claset * thm list -> claset
|
lcp@681
|
43 |
val addSDs : claset * thm list -> claset
|
lcp@681
|
44 |
val addSEs : claset * thm list -> claset
|
lcp@681
|
45 |
val addSIs : claset * thm list -> claset
|
paulson@1800
|
46 |
val delrules : claset * thm list -> claset
|
oheimb@2630
|
47 |
val setSWrapper : claset * ((int -> tactic) -> (int -> tactic)) ->claset
|
oheimb@2630
|
48 |
val compSWrapper : claset * ((int -> tactic) -> (int -> tactic)) ->claset
|
oheimb@2630
|
49 |
val setWrapper : claset * ((int -> tactic) -> (int -> tactic)) ->claset
|
oheimb@2630
|
50 |
val compWrapper : claset * ((int -> tactic) -> (int -> tactic)) ->claset
|
oheimb@2630
|
51 |
val addSbefore : claset * (int -> tactic) -> claset
|
oheimb@2630
|
52 |
val addSaltern : claset * (int -> tactic) -> claset
|
oheimb@2630
|
53 |
val addbefore : claset * (int -> tactic) -> claset
|
oheimb@2630
|
54 |
val addaltern : claset * (int -> tactic) -> claset
|
lcp@982
|
55 |
|
lcp@681
|
56 |
val print_cs : claset -> unit
|
lcp@1073
|
57 |
val rep_claset :
|
lcp@1073
|
58 |
claset -> {safeIs: thm list, safeEs: thm list,
|
lcp@1073
|
59 |
hazIs: thm list, hazEs: thm list,
|
oheimb@2630
|
60 |
uwrapper: (int -> tactic) -> (int -> tactic),
|
oheimb@2630
|
61 |
swrapper: (int -> tactic) -> (int -> tactic),
|
lcp@1073
|
62 |
safe0_netpair: netpair, safep_netpair: netpair,
|
lcp@1073
|
63 |
haz_netpair: netpair, dup_netpair: netpair}
|
oheimb@2630
|
64 |
val getWrapper : claset -> (int -> tactic) -> (int -> tactic)
|
oheimb@2630
|
65 |
val getSWrapper : claset -> (int -> tactic) -> (int -> tactic)
|
lcp@982
|
66 |
|
paulson@1587
|
67 |
val fast_tac : claset -> int -> tactic
|
paulson@1587
|
68 |
val slow_tac : claset -> int -> tactic
|
paulson@1587
|
69 |
val weight_ASTAR : int ref
|
paulson@1587
|
70 |
val astar_tac : claset -> int -> tactic
|
paulson@1587
|
71 |
val slow_astar_tac : claset -> int -> tactic
|
lcp@681
|
72 |
val best_tac : claset -> int -> tactic
|
paulson@1587
|
73 |
val slow_best_tac : claset -> int -> tactic
|
lcp@681
|
74 |
val depth_tac : claset -> int -> int -> tactic
|
lcp@681
|
75 |
val deepen_tac : claset -> int -> int -> tactic
|
paulson@1587
|
76 |
|
paulson@1587
|
77 |
val contr_tac : int -> tactic
|
lcp@681
|
78 |
val dup_elim : thm -> thm
|
lcp@681
|
79 |
val dup_intr : thm -> thm
|
lcp@681
|
80 |
val dup_step_tac : claset -> int -> tactic
|
lcp@681
|
81 |
val eq_mp_tac : int -> tactic
|
lcp@681
|
82 |
val haz_step_tac : claset -> int -> tactic
|
lcp@681
|
83 |
val joinrules : thm list * thm list -> (bool * thm) list
|
lcp@681
|
84 |
val mp_tac : int -> tactic
|
lcp@681
|
85 |
val safe_tac : claset -> tactic
|
lcp@681
|
86 |
val safe_step_tac : claset -> int -> tactic
|
paulson@3705
|
87 |
val clarify_tac : claset -> int -> tactic
|
paulson@3705
|
88 |
val clarify_step_tac : claset -> int -> tactic
|
lcp@681
|
89 |
val step_tac : claset -> int -> tactic
|
oheimb@2630
|
90 |
val slow_step_tac : claset -> int -> tactic
|
lcp@681
|
91 |
val swap : thm (* ~P ==> (~Q ==> P) ==> Q *)
|
lcp@681
|
92 |
val swapify : thm list -> thm list
|
lcp@681
|
93 |
val swap_res_tac : thm list -> int -> tactic
|
lcp@681
|
94 |
val inst_step_tac : claset -> int -> tactic
|
lcp@747
|
95 |
val inst0_step_tac : claset -> int -> tactic
|
lcp@747
|
96 |
val instp_step_tac : claset -> int -> tactic
|
berghofe@1724
|
97 |
|
berghofe@1724
|
98 |
val claset : claset ref
|
berghofe@1724
|
99 |
val AddDs : thm list -> unit
|
berghofe@1724
|
100 |
val AddEs : thm list -> unit
|
berghofe@1724
|
101 |
val AddIs : thm list -> unit
|
berghofe@1724
|
102 |
val AddSDs : thm list -> unit
|
berghofe@1724
|
103 |
val AddSEs : thm list -> unit
|
berghofe@1724
|
104 |
val AddSIs : thm list -> unit
|
paulson@1807
|
105 |
val Delrules : thm list -> unit
|
paulson@1814
|
106 |
val Safe_step_tac : int -> tactic
|
paulson@3705
|
107 |
val Clarify_tac : int -> tactic
|
paulson@3705
|
108 |
val Clarify_step_tac : int -> tactic
|
paulson@1800
|
109 |
val Step_tac : int -> tactic
|
berghofe@1724
|
110 |
val Fast_tac : int -> tactic
|
paulson@1800
|
111 |
val Best_tac : int -> tactic
|
paulson@2066
|
112 |
val Slow_tac : int -> tactic
|
paulson@2066
|
113 |
val Slow_best_tac : int -> tactic
|
paulson@1800
|
114 |
val Deepen_tac : int -> int -> tactic
|
berghofe@1724
|
115 |
|
clasohm@0
|
116 |
end;
|
clasohm@0
|
117 |
|
clasohm@0
|
118 |
|
clasohm@0
|
119 |
functor ClassicalFun(Data: CLASSICAL_DATA): CLASSICAL =
|
clasohm@0
|
120 |
struct
|
clasohm@0
|
121 |
|
clasohm@0
|
122 |
local open Data in
|
clasohm@0
|
123 |
|
paulson@1800
|
124 |
(*** Useful tactics for classical reasoning ***)
|
clasohm@0
|
125 |
|
paulson@1524
|
126 |
val imp_elim = (*cannot use bind_thm within a structure!*)
|
paulson@1524
|
127 |
store_thm ("imp_elim", make_elim mp);
|
clasohm@0
|
128 |
|
clasohm@0
|
129 |
(*Solve goal that assumes both P and ~P. *)
|
clasohm@0
|
130 |
val contr_tac = eresolve_tac [not_elim] THEN' assume_tac;
|
clasohm@0
|
131 |
|
lcp@681
|
132 |
(*Finds P-->Q and P in the assumptions, replaces implication by Q.
|
lcp@681
|
133 |
Could do the same thing for P<->Q and P... *)
|
lcp@681
|
134 |
fun mp_tac i = eresolve_tac [not_elim, imp_elim] i THEN assume_tac i;
|
clasohm@0
|
135 |
|
clasohm@0
|
136 |
(*Like mp_tac but instantiates no variables*)
|
lcp@681
|
137 |
fun eq_mp_tac i = ematch_tac [not_elim, imp_elim] i THEN eq_assume_tac i;
|
lcp@681
|
138 |
|
paulson@1524
|
139 |
val swap =
|
paulson@1524
|
140 |
store_thm ("swap", rule_by_tactic (etac thin_rl 1) (not_elim RS classical));
|
clasohm@0
|
141 |
|
clasohm@0
|
142 |
(*Creates rules to eliminate ~A, from rules to introduce A*)
|
clasohm@0
|
143 |
fun swapify intrs = intrs RLN (2, [swap]);
|
clasohm@0
|
144 |
|
clasohm@0
|
145 |
(*Uses introduction rules in the normal way, or on negated assumptions,
|
clasohm@0
|
146 |
trying rules in order. *)
|
clasohm@0
|
147 |
fun swap_res_tac rls =
|
lcp@54
|
148 |
let fun addrl (rl,brls) = (false, rl) :: (true, rl RSN (2,swap)) :: brls
|
lcp@54
|
149 |
in assume_tac ORELSE'
|
lcp@54
|
150 |
contr_tac ORELSE'
|
lcp@54
|
151 |
biresolve_tac (foldr addrl (rls,[]))
|
clasohm@0
|
152 |
end;
|
clasohm@0
|
153 |
|
lcp@681
|
154 |
(*Duplication of hazardous rules, for complete provers*)
|
paulson@2689
|
155 |
fun dup_intr th = zero_var_indexes (th RS classical);
|
lcp@681
|
156 |
|
lcp@681
|
157 |
fun dup_elim th = th RSN (2, revcut_rl) |> assumption 2 |> Sequence.hd |>
|
lcp@681
|
158 |
rule_by_tactic (TRYALL (etac revcut_rl));
|
clasohm@0
|
159 |
|
lcp@1073
|
160 |
|
paulson@1800
|
161 |
(**** Classical rule sets ****)
|
clasohm@0
|
162 |
|
clasohm@0
|
163 |
datatype claset =
|
lcp@982
|
164 |
CS of {safeIs : thm list, (*safe introduction rules*)
|
lcp@982
|
165 |
safeEs : thm list, (*safe elimination rules*)
|
lcp@982
|
166 |
hazIs : thm list, (*unsafe introduction rules*)
|
lcp@982
|
167 |
hazEs : thm list, (*unsafe elimination rules*)
|
oheimb@2630
|
168 |
uwrapper : (int -> tactic) ->
|
oheimb@2630
|
169 |
(int -> tactic), (*for transforming step_tac*)
|
oheimb@2630
|
170 |
swrapper : (int -> tactic) ->
|
oheimb@2630
|
171 |
(int -> tactic), (*for transform. safe_step_tac*)
|
lcp@982
|
172 |
safe0_netpair : netpair, (*nets for trivial cases*)
|
lcp@982
|
173 |
safep_netpair : netpair, (*nets for >0 subgoals*)
|
lcp@982
|
174 |
haz_netpair : netpair, (*nets for unsafe rules*)
|
lcp@982
|
175 |
dup_netpair : netpair}; (*nets for duplication*)
|
clasohm@0
|
176 |
|
lcp@1073
|
177 |
(*Desired invariants are
|
lcp@681
|
178 |
safe0_netpair = build safe0_brls,
|
lcp@681
|
179 |
safep_netpair = build safep_brls,
|
lcp@681
|
180 |
haz_netpair = build (joinrules(hazIs, hazEs)),
|
lcp@681
|
181 |
dup_netpair = build (joinrules(map dup_intr hazIs,
|
lcp@681
|
182 |
map dup_elim hazEs))}
|
lcp@1073
|
183 |
|
lcp@1073
|
184 |
where build = build_netpair(Net.empty,Net.empty),
|
lcp@1073
|
185 |
safe0_brls contains all brules that solve the subgoal, and
|
lcp@1073
|
186 |
safep_brls contains all brules that generate 1 or more new subgoals.
|
paulson@1800
|
187 |
The theorem lists are largely comments, though they are used in merge_cs.
|
lcp@1073
|
188 |
Nets must be built incrementally, to save space and time.
|
lcp@1073
|
189 |
*)
|
clasohm@0
|
190 |
|
lcp@1073
|
191 |
val empty_cs =
|
lcp@1073
|
192 |
CS{safeIs = [],
|
lcp@1073
|
193 |
safeEs = [],
|
lcp@1073
|
194 |
hazIs = [],
|
lcp@1073
|
195 |
hazEs = [],
|
oheimb@2630
|
196 |
uwrapper = I,
|
oheimb@2630
|
197 |
swrapper = I,
|
lcp@1073
|
198 |
safe0_netpair = (Net.empty,Net.empty),
|
lcp@1073
|
199 |
safep_netpair = (Net.empty,Net.empty),
|
lcp@1073
|
200 |
haz_netpair = (Net.empty,Net.empty),
|
lcp@1073
|
201 |
dup_netpair = (Net.empty,Net.empty)};
|
clasohm@0
|
202 |
|
wenzelm@3546
|
203 |
fun print_cs (CS {safeIs, safeEs, hazIs, hazEs, ...}) =
|
wenzelm@3546
|
204 |
let val pretty_thms = map Display.pretty_thm in
|
wenzelm@3546
|
205 |
Pretty.writeln (Pretty.big_list "introduction rules:" (pretty_thms hazIs));
|
wenzelm@3546
|
206 |
Pretty.writeln (Pretty.big_list "safe introduction rules:" (pretty_thms safeIs));
|
wenzelm@3546
|
207 |
Pretty.writeln (Pretty.big_list "elimination rules:" (pretty_thms hazEs));
|
wenzelm@3546
|
208 |
Pretty.writeln (Pretty.big_list "safe elimination rules:" (pretty_thms safeEs))
|
wenzelm@3546
|
209 |
end;
|
clasohm@0
|
210 |
|
lcp@1073
|
211 |
fun rep_claset (CS args) = args;
|
lcp@1073
|
212 |
|
oheimb@2630
|
213 |
fun getWrapper (CS{uwrapper,...}) = uwrapper;
|
oheimb@2630
|
214 |
|
oheimb@2630
|
215 |
fun getSWrapper (CS{swrapper,...}) = swrapper;
|
lcp@1073
|
216 |
|
lcp@1073
|
217 |
|
paulson@1800
|
218 |
(*** Adding (un)safe introduction or elimination rules.
|
lcp@1073
|
219 |
|
lcp@1073
|
220 |
In case of overlap, new rules are tried BEFORE old ones!!
|
paulson@1800
|
221 |
***)
|
clasohm@0
|
222 |
|
lcp@1073
|
223 |
(*For use with biresolve_tac. Combines intr rules with swap to handle negated
|
lcp@1073
|
224 |
assumptions. Pairs elim rules with true. *)
|
lcp@1073
|
225 |
fun joinrules (intrs,elims) =
|
lcp@1073
|
226 |
(map (pair true) (elims @ swapify intrs) @
|
lcp@1073
|
227 |
map (pair false) intrs);
|
lcp@1073
|
228 |
|
lcp@1073
|
229 |
(*Priority: prefer rules with fewest subgoals,
|
paulson@1231
|
230 |
then rules added most recently (preferring the head of the list).*)
|
lcp@1073
|
231 |
fun tag_brls k [] = []
|
lcp@1073
|
232 |
| tag_brls k (brl::brls) =
|
lcp@1073
|
233 |
(1000000*subgoals_of_brl brl + k, brl) ::
|
lcp@1073
|
234 |
tag_brls (k+1) brls;
|
lcp@1073
|
235 |
|
paulson@1800
|
236 |
fun insert_tagged_list kbrls netpr = foldr insert_tagged_brl (kbrls, netpr);
|
lcp@1073
|
237 |
|
lcp@1073
|
238 |
(*Insert into netpair that already has nI intr rules and nE elim rules.
|
lcp@1073
|
239 |
Count the intr rules double (to account for swapify). Negate to give the
|
lcp@1073
|
240 |
new insertions the lowest priority.*)
|
lcp@1073
|
241 |
fun insert (nI,nE) = insert_tagged_list o (tag_brls (~(2*nI+nE))) o joinrules;
|
lcp@1073
|
242 |
|
paulson@1800
|
243 |
fun delete_tagged_list brls netpr = foldr delete_tagged_brl (brls, netpr);
|
lcp@1073
|
244 |
|
paulson@1800
|
245 |
val delete = delete_tagged_list o joinrules;
|
paulson@1800
|
246 |
|
paulson@2813
|
247 |
val mem_thm = gen_mem eq_thm
|
paulson@2813
|
248 |
and rem_thm = gen_rem eq_thm;
|
paulson@2813
|
249 |
|
paulson@1927
|
250 |
(*Warn if the rule is already present ELSEWHERE in the claset. The addition
|
paulson@1927
|
251 |
is still allowed.*)
|
paulson@1927
|
252 |
fun warn_dup th (CS{safeIs, safeEs, hazIs, hazEs, ...}) =
|
paulson@2813
|
253 |
if mem_thm (th, safeIs) then
|
paulson@1927
|
254 |
warning ("rule already in claset as Safe Intr\n" ^ string_of_thm th)
|
paulson@2813
|
255 |
else if mem_thm (th, safeEs) then
|
paulson@1927
|
256 |
warning ("rule already in claset as Safe Elim\n" ^ string_of_thm th)
|
paulson@2813
|
257 |
else if mem_thm (th, hazIs) then
|
paulson@1927
|
258 |
warning ("rule already in claset as unsafe Intr\n" ^ string_of_thm th)
|
paulson@2813
|
259 |
else if mem_thm (th, hazEs) then
|
paulson@1927
|
260 |
warning ("rule already in claset as unsafe Elim\n" ^ string_of_thm th)
|
paulson@1927
|
261 |
else ();
|
paulson@1927
|
262 |
|
paulson@1800
|
263 |
(*** Safe rules ***)
|
lcp@982
|
264 |
|
oheimb@2630
|
265 |
fun addSI (cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@1927
|
266 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair},
|
paulson@1927
|
267 |
th) =
|
paulson@2813
|
268 |
if mem_thm (th, safeIs) then
|
paulson@1927
|
269 |
(warning ("ignoring duplicate Safe Intr\n" ^ string_of_thm th);
|
paulson@1927
|
270 |
cs)
|
paulson@1927
|
271 |
else
|
lcp@1073
|
272 |
let val (safe0_rls, safep_rls) = (*0 subgoals vs 1 or more*)
|
paulson@1927
|
273 |
partition (fn rl => nprems_of rl=0) [th]
|
paulson@1927
|
274 |
val nI = length safeIs + 1
|
lcp@1073
|
275 |
and nE = length safeEs
|
paulson@1927
|
276 |
in warn_dup th cs;
|
paulson@1927
|
277 |
CS{safeIs = th::safeIs,
|
lcp@1073
|
278 |
safe0_netpair = insert (nI,nE) (safe0_rls, []) safe0_netpair,
|
lcp@1073
|
279 |
safep_netpair = insert (nI,nE) (safep_rls, []) safep_netpair,
|
lcp@1073
|
280 |
safeEs = safeEs,
|
lcp@1073
|
281 |
hazIs = hazIs,
|
lcp@1073
|
282 |
hazEs = hazEs,
|
oheimb@2630
|
283 |
uwrapper = uwrapper,
|
oheimb@2630
|
284 |
swrapper = swrapper,
|
oheimb@2630
|
285 |
haz_netpair = haz_netpair,
|
oheimb@2630
|
286 |
dup_netpair = dup_netpair}
|
lcp@1073
|
287 |
end;
|
lcp@1073
|
288 |
|
oheimb@2630
|
289 |
fun addSE (cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@1927
|
290 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair},
|
paulson@1927
|
291 |
th) =
|
paulson@2813
|
292 |
if mem_thm (th, safeEs) then
|
paulson@1927
|
293 |
(warning ("ignoring duplicate Safe Elim\n" ^ string_of_thm th);
|
paulson@1927
|
294 |
cs)
|
paulson@1927
|
295 |
else
|
lcp@1073
|
296 |
let val (safe0_rls, safep_rls) = (*0 subgoals vs 1 or more*)
|
paulson@1927
|
297 |
partition (fn rl => nprems_of rl=1) [th]
|
lcp@1073
|
298 |
val nI = length safeIs
|
paulson@1927
|
299 |
and nE = length safeEs + 1
|
paulson@1927
|
300 |
in warn_dup th cs;
|
paulson@1927
|
301 |
CS{safeEs = th::safeEs,
|
lcp@1073
|
302 |
safe0_netpair = insert (nI,nE) ([], safe0_rls) safe0_netpair,
|
lcp@1073
|
303 |
safep_netpair = insert (nI,nE) ([], safep_rls) safep_netpair,
|
lcp@1073
|
304 |
safeIs = safeIs,
|
lcp@1073
|
305 |
hazIs = hazIs,
|
lcp@1073
|
306 |
hazEs = hazEs,
|
oheimb@2630
|
307 |
uwrapper = uwrapper,
|
oheimb@2630
|
308 |
swrapper = swrapper,
|
oheimb@2630
|
309 |
haz_netpair = haz_netpair,
|
oheimb@2630
|
310 |
dup_netpair = dup_netpair}
|
lcp@1073
|
311 |
end;
|
clasohm@0
|
312 |
|
paulson@1927
|
313 |
fun rev_foldl f (e, l) = foldl f (e, rev l);
|
paulson@1927
|
314 |
|
paulson@1927
|
315 |
val op addSIs = rev_foldl addSI;
|
paulson@1927
|
316 |
val op addSEs = rev_foldl addSE;
|
paulson@1927
|
317 |
|
clasohm@0
|
318 |
fun cs addSDs ths = cs addSEs (map make_elim ths);
|
clasohm@0
|
319 |
|
lcp@1073
|
320 |
|
paulson@1800
|
321 |
(*** Hazardous (unsafe) rules ***)
|
clasohm@0
|
322 |
|
oheimb@2630
|
323 |
fun addI (cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@1927
|
324 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair},
|
paulson@1927
|
325 |
th)=
|
paulson@2813
|
326 |
if mem_thm (th, hazIs) then
|
paulson@1927
|
327 |
(warning ("ignoring duplicate unsafe Intr\n" ^ string_of_thm th);
|
paulson@1927
|
328 |
cs)
|
paulson@1927
|
329 |
else
|
paulson@1927
|
330 |
let val nI = length hazIs + 1
|
lcp@1073
|
331 |
and nE = length hazEs
|
paulson@1927
|
332 |
in warn_dup th cs;
|
paulson@1927
|
333 |
CS{hazIs = th::hazIs,
|
paulson@1927
|
334 |
haz_netpair = insert (nI,nE) ([th], []) haz_netpair,
|
paulson@1927
|
335 |
dup_netpair = insert (nI,nE) (map dup_intr [th], []) dup_netpair,
|
lcp@1073
|
336 |
safeIs = safeIs,
|
lcp@1073
|
337 |
safeEs = safeEs,
|
lcp@1073
|
338 |
hazEs = hazEs,
|
oheimb@2630
|
339 |
uwrapper = uwrapper,
|
oheimb@2630
|
340 |
swrapper = swrapper,
|
lcp@1073
|
341 |
safe0_netpair = safe0_netpair,
|
lcp@1073
|
342 |
safep_netpair = safep_netpair}
|
lcp@1073
|
343 |
end;
|
lcp@1073
|
344 |
|
oheimb@2630
|
345 |
fun addE (cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@1927
|
346 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair},
|
paulson@1927
|
347 |
th) =
|
paulson@2813
|
348 |
if mem_thm (th, hazEs) then
|
paulson@1927
|
349 |
(warning ("ignoring duplicate unsafe Elim\n" ^ string_of_thm th);
|
paulson@1927
|
350 |
cs)
|
paulson@1927
|
351 |
else
|
lcp@1073
|
352 |
let val nI = length hazIs
|
paulson@1927
|
353 |
and nE = length hazEs + 1
|
paulson@1927
|
354 |
in warn_dup th cs;
|
paulson@1927
|
355 |
CS{hazEs = th::hazEs,
|
paulson@1927
|
356 |
haz_netpair = insert (nI,nE) ([], [th]) haz_netpair,
|
paulson@1927
|
357 |
dup_netpair = insert (nI,nE) ([], map dup_elim [th]) dup_netpair,
|
lcp@1073
|
358 |
safeIs = safeIs,
|
lcp@1073
|
359 |
safeEs = safeEs,
|
lcp@1073
|
360 |
hazIs = hazIs,
|
oheimb@2630
|
361 |
uwrapper = uwrapper,
|
oheimb@2630
|
362 |
swrapper = swrapper,
|
lcp@1073
|
363 |
safe0_netpair = safe0_netpair,
|
lcp@1073
|
364 |
safep_netpair = safep_netpair}
|
lcp@1073
|
365 |
end;
|
clasohm@0
|
366 |
|
paulson@1927
|
367 |
val op addIs = rev_foldl addI;
|
paulson@1927
|
368 |
val op addEs = rev_foldl addE;
|
paulson@1927
|
369 |
|
clasohm@0
|
370 |
fun cs addDs ths = cs addEs (map make_elim ths);
|
clasohm@0
|
371 |
|
lcp@1073
|
372 |
|
paulson@1800
|
373 |
(*** Deletion of rules
|
paulson@1800
|
374 |
Working out what to delete, requires repeating much of the code used
|
paulson@1800
|
375 |
to insert.
|
paulson@1927
|
376 |
Separate functions delSI, etc., are not exported; instead delrules
|
paulson@2813
|
377 |
searches in all the lists and chooses the relevant delXX functions.
|
paulson@1800
|
378 |
***)
|
paulson@1800
|
379 |
|
paulson@2813
|
380 |
fun delSI th
|
paulson@2813
|
381 |
(cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@2813
|
382 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair}) =
|
paulson@2813
|
383 |
if mem_thm (th, safeIs) then
|
paulson@2813
|
384 |
let val (safe0_rls, safep_rls) = partition (fn rl => nprems_of rl=0) [th]
|
paulson@2813
|
385 |
in CS{safe0_netpair = delete (safe0_rls, []) safe0_netpair,
|
paulson@2813
|
386 |
safep_netpair = delete (safep_rls, []) safep_netpair,
|
paulson@2813
|
387 |
safeIs = rem_thm (safeIs,th),
|
paulson@2813
|
388 |
safeEs = safeEs,
|
paulson@2813
|
389 |
hazIs = hazIs,
|
paulson@2813
|
390 |
hazEs = hazEs,
|
paulson@2813
|
391 |
uwrapper = uwrapper,
|
paulson@2813
|
392 |
swrapper = swrapper,
|
paulson@2813
|
393 |
haz_netpair = haz_netpair,
|
paulson@2813
|
394 |
dup_netpair = dup_netpair}
|
paulson@2813
|
395 |
end
|
paulson@2813
|
396 |
else cs;
|
paulson@1800
|
397 |
|
paulson@2813
|
398 |
fun delSE th
|
paulson@2813
|
399 |
(cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@2813
|
400 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair}) =
|
paulson@2813
|
401 |
if mem_thm (th, safeEs) then
|
paulson@2813
|
402 |
let val (safe0_rls, safep_rls) = partition (fn rl => nprems_of rl=1) [th]
|
paulson@2813
|
403 |
in CS{safe0_netpair = delete ([], safe0_rls) safe0_netpair,
|
paulson@2813
|
404 |
safep_netpair = delete ([], safep_rls) safep_netpair,
|
paulson@2813
|
405 |
safeIs = safeIs,
|
paulson@2813
|
406 |
safeEs = rem_thm (safeEs,th),
|
paulson@2813
|
407 |
hazIs = hazIs,
|
paulson@2813
|
408 |
hazEs = hazEs,
|
paulson@2813
|
409 |
uwrapper = uwrapper,
|
paulson@2813
|
410 |
swrapper = swrapper,
|
paulson@2813
|
411 |
haz_netpair = haz_netpair,
|
paulson@2813
|
412 |
dup_netpair = dup_netpair}
|
paulson@2813
|
413 |
end
|
paulson@2813
|
414 |
else cs;
|
paulson@1800
|
415 |
|
paulson@1800
|
416 |
|
paulson@2813
|
417 |
fun delI th
|
paulson@2813
|
418 |
(cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@2813
|
419 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair}) =
|
paulson@2813
|
420 |
if mem_thm (th, hazIs) then
|
paulson@2813
|
421 |
CS{haz_netpair = delete ([th], []) haz_netpair,
|
paulson@1800
|
422 |
dup_netpair = delete ([dup_intr th], []) dup_netpair,
|
paulson@1800
|
423 |
safeIs = safeIs,
|
paulson@1800
|
424 |
safeEs = safeEs,
|
paulson@2813
|
425 |
hazIs = rem_thm (hazIs,th),
|
paulson@1800
|
426 |
hazEs = hazEs,
|
oheimb@2630
|
427 |
uwrapper = uwrapper,
|
oheimb@2630
|
428 |
swrapper = swrapper,
|
paulson@1800
|
429 |
safe0_netpair = safe0_netpair,
|
paulson@2813
|
430 |
safep_netpair = safep_netpair}
|
paulson@2813
|
431 |
else cs;
|
paulson@1800
|
432 |
|
paulson@2813
|
433 |
fun delE th
|
paulson@2813
|
434 |
(cs as CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
paulson@2813
|
435 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair}) =
|
paulson@2813
|
436 |
if mem_thm (th, hazEs) then
|
paulson@2813
|
437 |
CS{haz_netpair = delete ([], [th]) haz_netpair,
|
paulson@1800
|
438 |
dup_netpair = delete ([], [dup_elim th]) dup_netpair,
|
paulson@1800
|
439 |
safeIs = safeIs,
|
paulson@1800
|
440 |
safeEs = safeEs,
|
paulson@1800
|
441 |
hazIs = hazIs,
|
paulson@2813
|
442 |
hazEs = rem_thm (hazEs,th),
|
oheimb@2630
|
443 |
uwrapper = uwrapper,
|
oheimb@2630
|
444 |
swrapper = swrapper,
|
paulson@1800
|
445 |
safe0_netpair = safe0_netpair,
|
paulson@2813
|
446 |
safep_netpair = safep_netpair}
|
paulson@2813
|
447 |
else cs;
|
paulson@1800
|
448 |
|
paulson@2813
|
449 |
(*Delete ALL occurrences of "th" in the claset (perhaps from several lists)*)
|
paulson@1800
|
450 |
fun delrule (cs as CS{safeIs, safeEs, hazIs, hazEs, ...}, th) =
|
paulson@2813
|
451 |
if mem_thm (th, safeIs) orelse mem_thm (th, safeEs) orelse
|
paulson@2813
|
452 |
mem_thm (th, hazIs) orelse mem_thm (th, hazEs)
|
paulson@2813
|
453 |
then delSI th (delSE th (delI th (delE th cs)))
|
paulson@2813
|
454 |
else (warning ("rule not in claset\n" ^ (string_of_thm th));
|
paulson@2813
|
455 |
cs);
|
paulson@1800
|
456 |
|
paulson@1800
|
457 |
val op delrules = foldl delrule;
|
paulson@1800
|
458 |
|
paulson@1800
|
459 |
|
oheimb@2630
|
460 |
(*** Setting or modifying the wrapper tacticals ***)
|
lcp@982
|
461 |
|
oheimb@2630
|
462 |
(*Set a new uwrapper*)
|
oheimb@2630
|
463 |
fun (CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
lcp@1073
|
464 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair, ...})
|
oheimb@2630
|
465 |
setWrapper new_uwrapper =
|
oheimb@2630
|
466 |
CS{safeIs = safeIs,
|
lcp@1073
|
467 |
safeEs = safeEs,
|
lcp@1073
|
468 |
hazIs = hazIs,
|
lcp@1073
|
469 |
hazEs = hazEs,
|
oheimb@2630
|
470 |
uwrapper = new_uwrapper,
|
oheimb@2630
|
471 |
swrapper = swrapper,
|
lcp@1073
|
472 |
safe0_netpair = safe0_netpair,
|
lcp@1073
|
473 |
safep_netpair = safep_netpair,
|
lcp@1073
|
474 |
haz_netpair = haz_netpair,
|
lcp@1073
|
475 |
dup_netpair = dup_netpair};
|
lcp@982
|
476 |
|
oheimb@2630
|
477 |
(*Set a new swrapper*)
|
oheimb@2630
|
478 |
fun (CS{safeIs, safeEs, hazIs, hazEs, uwrapper, swrapper,
|
oheimb@2630
|
479 |
safe0_netpair, safep_netpair, haz_netpair, dup_netpair, ...})
|
oheimb@2630
|
480 |
setSWrapper new_swrapper =
|
oheimb@2630
|
481 |
CS{safeIs = safeIs,
|
oheimb@2630
|
482 |
safeEs = safeEs,
|
oheimb@2630
|
483 |
hazIs = hazIs,
|
oheimb@2630
|
484 |
hazEs = hazEs,
|
oheimb@2630
|
485 |
uwrapper = uwrapper,
|
oheimb@2630
|
486 |
swrapper = new_swrapper,
|
oheimb@2630
|
487 |
safe0_netpair = safe0_netpair,
|
oheimb@2630
|
488 |
safep_netpair = safep_netpair,
|
oheimb@2630
|
489 |
haz_netpair = haz_netpair,
|
oheimb@2630
|
490 |
dup_netpair = dup_netpair};
|
lcp@982
|
491 |
|
oheimb@2630
|
492 |
(*Compose a tactical with the existing uwrapper*)
|
oheimb@2630
|
493 |
fun cs compWrapper uwrapper' = cs setWrapper (uwrapper' o getWrapper cs);
|
oheimb@2630
|
494 |
|
oheimb@2630
|
495 |
(*Compose a tactical with the existing swrapper*)
|
oheimb@2630
|
496 |
fun cs compSWrapper swrapper' = cs setSWrapper (swrapper' o getSWrapper cs);
|
lcp@982
|
497 |
|
oheimb@2630
|
498 |
(*compose a safe tactic sequentially before/alternatively after safe_step_tac*)
|
oheimb@2630
|
499 |
fun cs addSbefore tac1 = cs compSWrapper (fn tac2 => tac1 THEN_MAYBE' tac2);
|
oheimb@2630
|
500 |
fun cs addSaltern tac2 = cs compSWrapper (fn tac1 => tac1 ORELSE' tac2);
|
lcp@982
|
501 |
|
oheimb@2630
|
502 |
(*compose a tactic sequentially before/alternatively after the step tactic*)
|
oheimb@2630
|
503 |
fun cs addbefore tac1 = cs compWrapper (fn tac2 => tac1 THEN_MAYBE' tac2);
|
oheimb@2630
|
504 |
fun cs addaltern tac2 = cs compWrapper (fn tac1 => tac1 APPEND' tac2);
|
lcp@982
|
505 |
|
paulson@1711
|
506 |
(*Merge works by adding all new rules of the 2nd claset into the 1st claset.
|
paulson@1711
|
507 |
Merging the term nets may look more efficient, but the rather delicate
|
paulson@1711
|
508 |
treatment of priority might get muddled up.*)
|
paulson@1711
|
509 |
fun merge_cs
|
oheimb@2630
|
510 |
(cs as CS{safeIs, safeEs, hazIs, hazEs, ...},
|
paulson@1711
|
511 |
CS{safeIs=safeIs2, safeEs=safeEs2, hazIs=hazIs2, hazEs=hazEs2,...}) =
|
paulson@1711
|
512 |
let val safeIs' = gen_rems eq_thm (safeIs2,safeIs)
|
paulson@1711
|
513 |
val safeEs' = gen_rems eq_thm (safeEs2,safeEs)
|
oheimb@2630
|
514 |
val hazIs' = gen_rems eq_thm ( hazIs2, hazIs)
|
oheimb@2630
|
515 |
val hazEs' = gen_rems eq_thm ( hazEs2, hazEs)
|
paulson@1711
|
516 |
in cs addSIs safeIs'
|
paulson@1711
|
517 |
addSEs safeEs'
|
paulson@1711
|
518 |
addIs hazIs'
|
paulson@1711
|
519 |
addEs hazEs'
|
paulson@1711
|
520 |
end;
|
paulson@1711
|
521 |
|
lcp@982
|
522 |
|
paulson@1800
|
523 |
(**** Simple tactics for theorem proving ****)
|
clasohm@0
|
524 |
|
clasohm@0
|
525 |
(*Attack subgoals using safe inferences -- matching, not resolution*)
|
oheimb@2630
|
526 |
fun safe_step_tac (cs as CS{safe0_netpair,safep_netpair,...}) =
|
oheimb@2630
|
527 |
getSWrapper cs (FIRST' [
|
oheimb@2630
|
528 |
eq_assume_tac,
|
oheimb@2630
|
529 |
eq_mp_tac,
|
oheimb@2630
|
530 |
bimatch_from_nets_tac safe0_netpair,
|
oheimb@2630
|
531 |
FIRST' hyp_subst_tacs,
|
oheimb@2630
|
532 |
bimatch_from_nets_tac safep_netpair]);
|
clasohm@0
|
533 |
|
clasohm@0
|
534 |
(*Repeatedly attack subgoals using safe inferences -- it's deterministic!*)
|
oheimb@2630
|
535 |
fun safe_tac cs = REPEAT_DETERM_FIRST
|
oheimb@2630
|
536 |
(fn i => COND (has_fewer_prems i) no_tac (safe_step_tac cs i));
|
lcp@747
|
537 |
|
paulson@3705
|
538 |
|
paulson@3705
|
539 |
(*** Clarify_tac: do safe steps without causing branching ***)
|
paulson@3705
|
540 |
|
paulson@3705
|
541 |
fun nsubgoalsP n (k,brl) = (subgoals_of_brl brl = n);
|
paulson@3705
|
542 |
|
paulson@3705
|
543 |
(*version of bimatch_from_nets_tac that only applies rules that
|
paulson@3705
|
544 |
create precisely n subgoals.*)
|
paulson@3705
|
545 |
fun n_bimatch_from_nets_tac n =
|
paulson@3705
|
546 |
biresolution_from_nets_tac (orderlist o filter (nsubgoalsP n)) true;
|
paulson@3705
|
547 |
|
paulson@3705
|
548 |
fun eq_contr_tac i = ematch_tac [not_elim] i THEN eq_assume_tac i;
|
paulson@3705
|
549 |
val eq_assume_contr_tac = eq_assume_tac ORELSE' eq_contr_tac;
|
paulson@3705
|
550 |
|
paulson@3705
|
551 |
(*Two-way branching is allowed only if one of the branches immediately closes*)
|
paulson@3705
|
552 |
fun bimatch2_tac netpair i =
|
paulson@3705
|
553 |
n_bimatch_from_nets_tac 2 netpair i THEN
|
paulson@3705
|
554 |
(eq_assume_contr_tac i ORELSE eq_assume_contr_tac (i+1));
|
paulson@3705
|
555 |
|
paulson@3705
|
556 |
(*Attack subgoals using safe inferences -- matching, not resolution*)
|
paulson@3705
|
557 |
fun clarify_step_tac (cs as CS{safe0_netpair,safep_netpair,...}) =
|
paulson@3705
|
558 |
getSWrapper cs (FIRST' [
|
paulson@3705
|
559 |
eq_assume_contr_tac,
|
paulson@3705
|
560 |
bimatch_from_nets_tac safe0_netpair,
|
paulson@3705
|
561 |
FIRST' hyp_subst_tacs,
|
paulson@3705
|
562 |
n_bimatch_from_nets_tac 1 safep_netpair,
|
paulson@3705
|
563 |
bimatch2_tac safep_netpair]);
|
paulson@3705
|
564 |
|
paulson@3705
|
565 |
fun clarify_tac cs = SELECT_GOAL (REPEAT_DETERM (clarify_step_tac cs 1));
|
paulson@3705
|
566 |
|
paulson@3705
|
567 |
|
paulson@3705
|
568 |
(*** Unsafe steps instantiate variables or lose information ***)
|
paulson@3705
|
569 |
|
lcp@747
|
570 |
(*But these unsafe steps at least solve a subgoal!*)
|
lcp@747
|
571 |
fun inst0_step_tac (CS{safe0_netpair,safep_netpair,...}) =
|
lcp@747
|
572 |
assume_tac APPEND'
|
lcp@747
|
573 |
contr_tac APPEND'
|
lcp@747
|
574 |
biresolve_from_nets_tac safe0_netpair;
|
lcp@747
|
575 |
|
lcp@747
|
576 |
(*These are much worse since they could generate more and more subgoals*)
|
lcp@747
|
577 |
fun instp_step_tac (CS{safep_netpair,...}) =
|
lcp@747
|
578 |
biresolve_from_nets_tac safep_netpair;
|
clasohm@0
|
579 |
|
clasohm@0
|
580 |
(*These steps could instantiate variables and are therefore unsafe.*)
|
lcp@747
|
581 |
fun inst_step_tac cs = inst0_step_tac cs APPEND' instp_step_tac cs;
|
clasohm@0
|
582 |
|
lcp@982
|
583 |
fun haz_step_tac (CS{haz_netpair,...}) =
|
lcp@681
|
584 |
biresolve_from_nets_tac haz_netpair;
|
lcp@681
|
585 |
|
clasohm@0
|
586 |
(*Single step for the prover. FAILS unless it makes progress. *)
|
oheimb@2630
|
587 |
fun step_tac cs i = getWrapper cs
|
oheimb@2630
|
588 |
(K (safe_tac cs) ORELSE' (inst_step_tac cs ORELSE' haz_step_tac cs)) i;
|
clasohm@0
|
589 |
|
clasohm@0
|
590 |
(*Using a "safe" rule to instantiate variables is unsafe. This tactic
|
clasohm@0
|
591 |
allows backtracking from "safe" rules to "unsafe" rules here.*)
|
oheimb@2630
|
592 |
fun slow_step_tac cs i = getWrapper cs
|
oheimb@2630
|
593 |
(K (safe_tac cs) ORELSE' (inst_step_tac cs APPEND' haz_step_tac cs)) i;
|
clasohm@0
|
594 |
|
paulson@1800
|
595 |
(**** The following tactics all fail unless they solve one goal ****)
|
clasohm@0
|
596 |
|
clasohm@0
|
597 |
(*Dumb but fast*)
|
clasohm@0
|
598 |
fun fast_tac cs = SELECT_GOAL (DEPTH_SOLVE (step_tac cs 1));
|
clasohm@0
|
599 |
|
clasohm@0
|
600 |
(*Slower but smarter than fast_tac*)
|
clasohm@0
|
601 |
fun best_tac cs =
|
clasohm@0
|
602 |
SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, sizef) (step_tac cs 1));
|
clasohm@0
|
603 |
|
clasohm@0
|
604 |
fun slow_tac cs = SELECT_GOAL (DEPTH_SOLVE (slow_step_tac cs 1));
|
clasohm@0
|
605 |
|
clasohm@0
|
606 |
fun slow_best_tac cs =
|
clasohm@0
|
607 |
SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, sizef) (slow_step_tac cs 1));
|
clasohm@0
|
608 |
|
lcp@681
|
609 |
|
paulson@1800
|
610 |
(***ASTAR with weight weight_ASTAR, by Norbert Voelker*)
|
paulson@1587
|
611 |
val weight_ASTAR = ref 5;
|
paulson@1587
|
612 |
|
paulson@1587
|
613 |
fun astar_tac cs =
|
paulson@1587
|
614 |
SELECT_GOAL ( ASTAR (has_fewer_prems 1
|
paulson@1587
|
615 |
, fn level =>(fn thm =>size_of_thm thm + !weight_ASTAR *level))
|
paulson@1587
|
616 |
(step_tac cs 1));
|
paulson@1587
|
617 |
|
paulson@1587
|
618 |
fun slow_astar_tac cs =
|
paulson@1587
|
619 |
SELECT_GOAL ( ASTAR (has_fewer_prems 1
|
paulson@1587
|
620 |
, fn level =>(fn thm =>size_of_thm thm + !weight_ASTAR *level))
|
paulson@1587
|
621 |
(slow_step_tac cs 1));
|
paulson@1587
|
622 |
|
paulson@1800
|
623 |
(**** Complete tactic, loosely based upon LeanTaP. This tactic is the outcome
|
lcp@747
|
624 |
of much experimentation! Changing APPEND to ORELSE below would prove
|
lcp@747
|
625 |
easy theorems faster, but loses completeness -- and many of the harder
|
paulson@1800
|
626 |
theorems such as 43. ****)
|
lcp@681
|
627 |
|
lcp@747
|
628 |
(*Non-deterministic! Could always expand the first unsafe connective.
|
lcp@747
|
629 |
That's hard to implement and did not perform better in experiments, due to
|
lcp@747
|
630 |
greater search depth required.*)
|
lcp@681
|
631 |
fun dup_step_tac (cs as (CS{dup_netpair,...})) =
|
lcp@681
|
632 |
biresolve_from_nets_tac dup_netpair;
|
lcp@681
|
633 |
|
lcp@747
|
634 |
(*Searching to depth m.*)
|
paulson@3537
|
635 |
fun depth_tac cs m i state =
|
lcp@747
|
636 |
SELECT_GOAL
|
oheimb@2630
|
637 |
(getWrapper cs
|
oheimb@3204
|
638 |
(fn i => REPEAT_DETERM1 (COND (has_fewer_prems i) no_tac
|
oheimb@3204
|
639 |
(safe_step_tac cs i)) THEN_ELSE
|
oheimb@2630
|
640 |
(DEPTH_SOLVE (depth_tac cs m i),
|
oheimb@2630
|
641 |
inst0_step_tac cs i APPEND
|
lcp@747
|
642 |
COND (K(m=0)) no_tac
|
oheimb@2630
|
643 |
((instp_step_tac cs i APPEND dup_step_tac cs i)
|
oheimb@2630
|
644 |
THEN DEPTH_SOLVE (depth_tac cs (m-1) i)))) 1)
|
paulson@3537
|
645 |
i state;
|
lcp@747
|
646 |
|
paulson@2173
|
647 |
(*Search, with depth bound m.
|
paulson@2173
|
648 |
This is the "entry point", which does safe inferences first.*)
|
lcp@747
|
649 |
fun safe_depth_tac cs m =
|
lcp@681
|
650 |
SUBGOAL
|
lcp@681
|
651 |
(fn (prem,i) =>
|
lcp@681
|
652 |
let val deti =
|
lcp@681
|
653 |
(*No Vars in the goal? No need to backtrack between goals.*)
|
lcp@681
|
654 |
case term_vars prem of
|
lcp@681
|
655 |
[] => DETERM
|
lcp@681
|
656 |
| _::_ => I
|
lcp@681
|
657 |
in SELECT_GOAL (TRY (safe_tac cs) THEN
|
lcp@747
|
658 |
DEPTH_SOLVE (deti (depth_tac cs m 1))) i
|
lcp@747
|
659 |
end);
|
lcp@681
|
660 |
|
paulson@2868
|
661 |
fun deepen_tac cs = DEEPEN (2,10) (safe_depth_tac cs);
|
lcp@681
|
662 |
|
berghofe@1724
|
663 |
val claset = ref empty_cs;
|
berghofe@1724
|
664 |
|
berghofe@1724
|
665 |
fun AddDs ts = (claset := !claset addDs ts);
|
berghofe@1724
|
666 |
|
berghofe@1724
|
667 |
fun AddEs ts = (claset := !claset addEs ts);
|
berghofe@1724
|
668 |
|
berghofe@1724
|
669 |
fun AddIs ts = (claset := !claset addIs ts);
|
berghofe@1724
|
670 |
|
berghofe@1724
|
671 |
fun AddSDs ts = (claset := !claset addSDs ts);
|
berghofe@1724
|
672 |
|
berghofe@1724
|
673 |
fun AddSEs ts = (claset := !claset addSEs ts);
|
berghofe@1724
|
674 |
|
berghofe@1724
|
675 |
fun AddSIs ts = (claset := !claset addSIs ts);
|
berghofe@1724
|
676 |
|
paulson@1807
|
677 |
fun Delrules ts = (claset := !claset delrules ts);
|
paulson@1807
|
678 |
|
paulson@1800
|
679 |
(*Cannot have Safe_tac, as it takes no arguments; must delay dereferencing!*)
|
paulson@1800
|
680 |
|
paulson@1814
|
681 |
fun Safe_step_tac i = safe_step_tac (!claset) i;
|
paulson@1814
|
682 |
|
paulson@3705
|
683 |
fun Clarify_step_tac i = clarify_step_tac (!claset) i;
|
paulson@3705
|
684 |
|
paulson@3705
|
685 |
fun Clarify_tac i = clarify_tac (!claset) i;
|
paulson@3705
|
686 |
|
paulson@1800
|
687 |
fun Step_tac i = step_tac (!claset) i;
|
paulson@1800
|
688 |
|
berghofe@1724
|
689 |
fun Fast_tac i = fast_tac (!claset) i;
|
berghofe@1724
|
690 |
|
paulson@1800
|
691 |
fun Best_tac i = best_tac (!claset) i;
|
paulson@1800
|
692 |
|
paulson@2066
|
693 |
fun Slow_tac i = slow_tac (!claset) i;
|
paulson@2066
|
694 |
|
paulson@2066
|
695 |
fun Slow_best_tac i = slow_best_tac (!claset) i;
|
paulson@2066
|
696 |
|
paulson@1800
|
697 |
fun Deepen_tac m = deepen_tac (!claset) m;
|
paulson@1800
|
698 |
|
clasohm@0
|
699 |
end;
|
clasohm@0
|
700 |
end;
|
oheimb@2630
|
701 |
|
oheimb@2630
|
702 |
|