126 |
126 |
127 (*forces the first argument to be a proposition if necessary*) |
127 (*forces the first argument to be a proposition if necessary*) |
128 fun DISCH tm thm = Thm.implies_intr (D.mk_prop tm) thm COMP impI |
128 fun DISCH tm thm = Thm.implies_intr (D.mk_prop tm) thm COMP impI |
129 handle THM (msg, _, _) => raise RULES_ERR "DISCH" msg; |
129 handle THM (msg, _, _) => raise RULES_ERR "DISCH" msg; |
130 |
130 |
131 fun DISCH_ALL thm = U.itlist DISCH (#hyps (Thm.crep_thm thm)) thm; |
131 fun DISCH_ALL thm = fold_rev DISCH (#hyps (Thm.crep_thm thm)) thm; |
132 |
132 |
133 |
133 |
134 fun FILTER_DISCH_ALL P thm = |
134 fun FILTER_DISCH_ALL P thm = |
135 let fun check tm = P (#t (Thm.rep_cterm tm)) |
135 let fun check tm = P (#t (Thm.rep_cterm tm)) |
136 in foldr (fn (tm,th) => if check tm then DISCH tm th else th) |
136 in foldr (fn (tm,th) => if check tm then DISCH tm th else th) |
200 fun EVEN_ORS thms = |
200 fun EVEN_ORS thms = |
201 let fun blue ldisjs [] _ = [] |
201 let fun blue ldisjs [] _ = [] |
202 | blue ldisjs (th::rst) rdisjs = |
202 | blue ldisjs (th::rst) rdisjs = |
203 let val tail = tl rdisjs |
203 let val tail = tl rdisjs |
204 val rdisj_tl = D.list_mk_disj tail |
204 val rdisj_tl = D.list_mk_disj tail |
205 in U.itlist DISJ2 ldisjs (DISJ1 th rdisj_tl) |
205 in fold_rev DISJ2 ldisjs (DISJ1 th rdisj_tl) |
206 :: blue (ldisjs @ [cconcl th]) rst tail |
206 :: blue (ldisjs @ [cconcl th]) rst tail |
207 end handle U.ERR _ => [U.itlist DISJ2 ldisjs th] |
207 end handle U.ERR _ => [fold_rev DISJ2 ldisjs th] |
208 in blue [] thms (map cconcl thms) end; |
208 in blue [] thms (map cconcl thms) end; |
209 |
209 |
210 |
210 |
211 (*---------------------------------------------------------------------------- |
211 (*---------------------------------------------------------------------------- |
212 * |
212 * |
285 in |
285 in |
286 thm RS (forall_elim tm gspec') |
286 thm RS (forall_elim tm gspec') |
287 end |
287 end |
288 end; |
288 end; |
289 |
289 |
290 fun SPEC_ALL thm = U.rev_itlist SPEC (#1(D.strip_forall(cconcl thm))) thm; |
290 fun SPEC_ALL thm = fold SPEC (#1(D.strip_forall(cconcl thm))) thm; |
291 |
291 |
292 val ISPEC = SPEC |
292 val ISPEC = SPEC |
293 val ISPECL = U.rev_itlist ISPEC; |
293 val ISPECL = fold ISPEC; |
294 |
294 |
295 (* Not optimized! Too complicated. *) |
295 (* Not optimized! Too complicated. *) |
296 local val {prop,sign,...} = rep_thm allI |
296 local val {prop,sign,...} = rep_thm allI |
297 val [P] = add_term_vars (prop, []) |
297 val [P] = add_term_vars (prop, []) |
298 fun cty_theta s = map (fn (i, (S, ty)) => (ctyp_of s (TVar (i, S)), ctyp_of s ty)) |
298 fun cty_theta s = map (fn (i, (S, ty)) => (ctyp_of s (TVar (i, S)), ctyp_of s ty)) |
316 val prop' = tp $ (A $ Abs(x,ty,M)) |
316 val prop' = tp $ (A $ Abs(x,ty,M)) |
317 in ALPHA thm (cterm_of sign prop') |
317 in ALPHA thm (cterm_of sign prop') |
318 end |
318 end |
319 end; |
319 end; |
320 |
320 |
321 val GENL = U.itlist GEN; |
321 val GENL = fold_rev GEN; |
322 |
322 |
323 fun GEN_ALL thm = |
323 fun GEN_ALL thm = |
324 let val {prop,sign,...} = rep_thm thm |
324 let val {prop,sign,...} = rep_thm thm |
325 val tycheck = cterm_of sign |
325 val tycheck = cterm_of sign |
326 val vlist = map tycheck (add_term_vars (prop, [])) |
326 val vlist = map tycheck (add_term_vars (prop, [])) |
381 * A |- ?v1...v_n. M |
381 * A |- ?v1...v_n. M |
382 * |
382 * |
383 *---------------------------------------------------------------------------*) |
383 *---------------------------------------------------------------------------*) |
384 |
384 |
385 fun EXISTL vlist th = |
385 fun EXISTL vlist th = |
386 U.itlist (fn v => fn thm => EXISTS(D.mk_exists(v,cconcl thm), v) thm) |
386 fold_rev (fn v => fn thm => EXISTS(D.mk_exists(v,cconcl thm), v) thm) |
387 vlist th; |
387 vlist th; |
388 |
388 |
389 |
389 |
390 (*---------------------------------------------------------------------------- |
390 (*---------------------------------------------------------------------------- |
391 * |
391 * |
402 val detype = #t o rep_cterm |
402 val detype = #t o rep_cterm |
403 val blist' = map (fn (x,y) => (detype x, detype y)) blist |
403 val blist' = map (fn (x,y) => (detype x, detype y)) blist |
404 fun ?v M = cterm_of sign (S.mk_exists{Bvar=v,Body = M}) |
404 fun ?v M = cterm_of sign (S.mk_exists{Bvar=v,Body = M}) |
405 |
405 |
406 in |
406 in |
407 U.itlist (fn (b as (r1,r2)) => fn thm => |
407 fold_rev (fn (b as (r1,r2)) => fn thm => |
408 EXISTS(?r2(subst_free[b] |
408 EXISTS(?r2(subst_free[b] |
409 (HOLogic.dest_Trueprop(#prop(rep_thm thm)))), tych r1) |
409 (HOLogic.dest_Trueprop(#prop(rep_thm thm)))), tych r1) |
410 thm) |
410 thm) |
411 blist' th |
411 blist' th |
412 end; |
412 end; |
525 let val {prop,sign,...} = rep_thm thm |
525 let val {prop,sign,...} = rep_thm thm |
526 val tych = cterm_of sign |
526 val tych = cterm_of sign |
527 val ants = Logic.strip_imp_prems prop |
527 val ants = Logic.strip_imp_prems prop |
528 val news = get (ants,1,[]) |
528 val news = get (ants,1,[]) |
529 in |
529 in |
530 U.rev_itlist rename_params_rule news thm |
530 fold rename_params_rule news thm |
531 end; |
531 end; |
532 |
532 |
533 |
533 |
534 (*--------------------------------------------------------------------------- |
534 (*--------------------------------------------------------------------------- |
535 * Beta-conversion to the rhs of an equation (taken from hol90/drule.sml) |
535 * Beta-conversion to the rhs of an equation (taken from hol90/drule.sml) |
565 fun mk_aabs (vstr, body) = |
565 fun mk_aabs (vstr, body) = |
566 S.mk_abs {Bvar = vstr, Body = body} |
566 S.mk_abs {Bvar = vstr, Body = body} |
567 handle U.ERR _ => S.mk_pabs {varstruct = vstr, body = body}; |
567 handle U.ERR _ => S.mk_pabs {varstruct = vstr, body = body}; |
568 |
568 |
569 fun list_mk_aabs (vstrl,tm) = |
569 fun list_mk_aabs (vstrl,tm) = |
570 U.itlist (fn vstr => fn tm => mk_aabs(vstr,tm)) vstrl tm; |
570 fold_rev (fn vstr => fn tm => mk_aabs(vstr,tm)) vstrl tm; |
571 |
571 |
572 fun dest_aabs used tm = |
572 fun dest_aabs used tm = |
573 let val ({Bvar,Body}, used') = S.dest_abs used tm |
573 let val ({Bvar,Body}, used') = S.dest_abs used tm |
574 in (Bvar, Body, used') end |
574 in (Bvar, Body, used') end |
575 handle U.ERR _ => |
575 handle U.ERR _ => |
763 val dummy = print_thms "cntxt:" cntxt |
763 val dummy = print_thms "cntxt:" cntxt |
764 val {prop = Const("==>",_) $ (Const("Trueprop",_) $ A) $ _, |
764 val {prop = Const("==>",_) $ (Const("Trueprop",_) $ A) $ _, |
765 sign,...} = rep_thm thm |
765 sign,...} = rep_thm thm |
766 fun genl tm = let val vlist = gen_rems (op aconv) |
766 fun genl tm = let val vlist = gen_rems (op aconv) |
767 (add_term_frees(tm,[]), globals) |
767 (add_term_frees(tm,[]), globals) |
768 in U.itlist Forall vlist tm |
768 in fold_rev Forall vlist tm |
769 end |
769 end |
770 (*-------------------------------------------------------------- |
770 (*-------------------------------------------------------------- |
771 * This actually isn't quite right, since it will think that |
771 * This actually isn't quite right, since it will think that |
772 * not-fully applied occs. of "f" in the context mean that the |
772 * not-fully applied occs. of "f" in the context mean that the |
773 * current call is nested. The real solution is to pass in a |
773 * current call is nested. The real solution is to pass in a |