200 (*True if the given type contains bool anywhere*) |
200 (*True if the given type contains bool anywhere*) |
201 fun has_bool (Type("bool",_)) = true |
201 fun has_bool (Type("bool",_)) = true |
202 | has_bool (Type(_, Ts)) = exists has_bool Ts |
202 | has_bool (Type(_, Ts)) = exists has_bool Ts |
203 | has_bool _ = false; |
203 | has_bool _ = false; |
204 |
204 |
|
205 (*Is the string the name of a connective? It doesn't matter if this list is |
|
206 incomplete, since when actually called, the only connectives likely to |
|
207 remain are & | Not.*) |
|
208 fun is_conn c = c mem_string |
|
209 ["Trueprop", "op &", "op |", "op -->", "op =", "Not", |
|
210 "All", "Ex", "Ball", "Bex"]; |
|
211 |
|
212 (*True if the term contains a function where the type of any argument contains |
|
213 bool.*) |
|
214 val has_bool_arg_const = |
|
215 exists_Const |
|
216 (fn (c,T) => not(is_conn c) andalso exists (has_bool) (binder_types T)); |
|
217 |
205 (*Raises an exception if any Vars in the theorem mention type bool. That would mean |
218 (*Raises an exception if any Vars in the theorem mention type bool. That would mean |
206 they are higher-order, and in addition, they could cause make_horn to loop!*) |
219 they are higher-order, and in addition, they could cause make_horn to loop! |
|
220 Functions taking Boolean arguments are also rejected.*) |
207 fun check_no_bool th = |
221 fun check_no_bool th = |
208 if exists (has_bool o fastype_of) (term_vars (#prop (rep_thm th))) |
222 let val {prop,...} = rep_thm th |
209 then raise THM ("check_no_bool", 0, [th]) else th; |
223 in if exists (has_bool o fastype_of) (term_vars prop) orelse |
|
224 has_bool_arg_const prop |
|
225 then raise THM ("check_no_bool", 0, [th]) else th |
|
226 end; |
210 |
227 |
211 (*Create a meta-level Horn clause*) |
228 (*Create a meta-level Horn clause*) |
212 fun make_horn crules th = make_horn crules (tryres(th,crules)) |
229 fun make_horn crules th = make_horn crules (tryres(th,crules)) |
213 handle THM _ => th; |
230 handle THM _ => th; |
214 |
231 |
268 |
285 |
269 (* net_resolve_tac actually made it slower... *) |
286 (* net_resolve_tac actually made it slower... *) |
270 fun prolog_step_tac horns i = |
287 fun prolog_step_tac horns i = |
271 (assume_tac i APPEND resolve_tac horns i) THEN check_tac THEN |
288 (assume_tac i APPEND resolve_tac horns i) THEN check_tac THEN |
272 TRYALL eq_assume_tac; |
289 TRYALL eq_assume_tac; |
273 |
|
274 |
|
275 |
|
276 |
|
277 |
290 |
278 (*Sums the sizes of the subgoals, ignoring hypotheses (ancestors)*) |
291 (*Sums the sizes of the subgoals, ignoring hypotheses (ancestors)*) |
279 fun addconcl(prem,sz) = size_of_term(Logic.strip_assums_concl prem) + sz |
292 fun addconcl(prem,sz) = size_of_term(Logic.strip_assums_concl prem) + sz |
280 |
293 |
281 fun size_of_subgoals st = foldr addconcl 0 (prems_of st); |
294 fun size_of_subgoals st = foldr addconcl 0 (prems_of st); |