291 ctm_theta s (Vartab.dest tm_theta)) |
291 ctm_theta s (Vartab.dest tm_theta)) |
292 in |
292 in |
293 fun GEN v th = |
293 fun GEN v th = |
294 let val gth = Thm.forall_intr v th |
294 let val gth = Thm.forall_intr v th |
295 val thy = Thm.theory_of_thm gth |
295 val thy = Thm.theory_of_thm gth |
296 val Const("all",_)$Abs(x,ty,rst) = Thm.prop_of gth |
296 val Const(@{const_name Pure.all},_)$Abs(x,ty,rst) = Thm.prop_of gth |
297 val P' = Abs(x,ty, HOLogic.dest_Trueprop rst) (* get rid of trueprop *) |
297 val P' = Abs(x,ty, HOLogic.dest_Trueprop rst) (* get rid of trueprop *) |
298 val theta = Pattern.match thy (P,P') (Vartab.empty, Vartab.empty); |
298 val theta = Pattern.match thy (P,P') (Vartab.empty, Vartab.empty); |
299 val allI2 = Drule.instantiate_normalize (certify thy theta) allI |
299 val allI2 = Drule.instantiate_normalize (certify thy theta) allI |
300 val thm = Thm.implies_elim allI2 gth |
300 val thm = Thm.implies_elim allI2 gth |
301 val tp $ (A $ Abs(_,_,M)) = Thm.prop_of thm |
301 val tp $ (A $ Abs(_,_,M)) = Thm.prop_of thm |
439 fun Forall v M = USyntax.mk_forall{Bvar=v, Body=M}; |
439 fun Forall v M = USyntax.mk_forall{Bvar=v, Body=M}; |
440 |
440 |
441 |
441 |
442 (* Fragile: it's a cong if it is not "R y x ==> cut f R x y = f y" *) |
442 (* Fragile: it's a cong if it is not "R y x ==> cut f R x y = f y" *) |
443 fun is_cong thm = |
443 fun is_cong thm = |
444 case (Thm.prop_of thm) |
444 case (Thm.prop_of thm) of |
445 of (Const("==>",_)$(Const(@{const_name Trueprop},_)$ _) $ |
445 (Const(@{const_name Pure.imp},_)$(Const(@{const_name Trueprop},_)$ _) $ |
446 (Const("==",_) $ (Const (@{const_name Wfrec.cut},_) $ f $ R $ a $ x) $ _)) => false |
446 (Const(@{const_name Pure.eq},_) $ (Const (@{const_name Wfrec.cut},_) $ f $ R $ a $ x) $ _)) => |
447 | _ => true; |
447 false |
448 |
448 | _ => true; |
449 |
449 |
450 fun dest_equal(Const ("==",_) $ |
450 |
|
451 fun dest_equal(Const (@{const_name Pure.eq},_) $ |
451 (Const (@{const_name Trueprop},_) $ lhs) |
452 (Const (@{const_name Trueprop},_) $ lhs) |
452 $ (Const (@{const_name Trueprop},_) $ rhs)) = {lhs=lhs, rhs=rhs} |
453 $ (Const (@{const_name Trueprop},_) $ rhs)) = {lhs=lhs, rhs=rhs} |
453 | dest_equal(Const ("==",_) $ lhs $ rhs) = {lhs=lhs, rhs=rhs} |
454 | dest_equal(Const (@{const_name Pure.eq},_) $ lhs $ rhs) = {lhs=lhs, rhs=rhs} |
454 | dest_equal tm = USyntax.dest_eq tm; |
455 | dest_equal tm = USyntax.dest_eq tm; |
455 |
456 |
456 fun get_lhs tm = #lhs(dest_equal (HOLogic.dest_Trueprop tm)); |
457 fun get_lhs tm = #lhs(dest_equal (HOLogic.dest_Trueprop tm)); |
457 |
458 |
458 fun dest_all used (Const("all",_) $ (a as Abs _)) = USyntax.dest_abs used a |
459 fun dest_all used (Const(@{const_name Pure.all},_) $ (a as Abs _)) = USyntax.dest_abs used a |
459 | dest_all _ _ = raise RULES_ERR "dest_all" "not a !!"; |
460 | dest_all _ _ = raise RULES_ERR "dest_all" "not a !!"; |
460 |
461 |
461 val is_all = can (dest_all []); |
462 val is_all = can (dest_all []); |
462 |
463 |
463 fun strip_all used fm = |
464 fun strip_all used fm = |
466 val (bvs, core, used'') = strip_all used' Body |
467 val (bvs, core, used'') = strip_all used' Body |
467 in ((Bvar::bvs), core, used'') |
468 in ((Bvar::bvs), core, used'') |
468 end |
469 end |
469 else ([], fm, used); |
470 else ([], fm, used); |
470 |
471 |
471 fun break_all(Const("all",_) $ Abs (_,_,body)) = body |
472 fun break_all(Const(@{const_name Pure.all},_) $ Abs (_,_,body)) = body |
472 | break_all _ = raise RULES_ERR "break_all" "not a !!"; |
473 | break_all _ = raise RULES_ERR "break_all" "not a !!"; |
473 |
474 |
474 fun list_break_all(Const("all",_) $ Abs (s,ty,body)) = |
475 fun list_break_all(Const(@{const_name Pure.all},_) $ Abs (s,ty,body)) = |
475 let val (L,core) = list_break_all body |
476 let val (L,core) = list_break_all body |
476 in ((s,ty)::L, core) |
477 in ((s,ty)::L, core) |
477 end |
478 end |
478 | list_break_all tm = ([],tm); |
479 | list_break_all tm = ([],tm); |
479 |
480 |
723 ant_th COMP thm |
724 ant_th COMP thm |
724 end end |
725 end end |
725 |
726 |
726 fun eliminate thm = |
727 fun eliminate thm = |
727 case Thm.prop_of thm |
728 case Thm.prop_of thm |
728 of Const("==>",_) $ imp $ _ => |
729 of Const(@{const_name Pure.imp},_) $ imp $ _ => |
729 eliminate |
730 eliminate |
730 (if not(is_all imp) |
731 (if not(is_all imp) |
731 then uq_eliminate (thm, imp, Thm.theory_of_thm thm) |
732 then uq_eliminate (thm, imp, Thm.theory_of_thm thm) |
732 else q_eliminate (thm, imp, Thm.theory_of_thm thm)) |
733 else q_eliminate (thm, imp, Thm.theory_of_thm thm)) |
733 (* Assume that the leading constant is ==, *) |
734 (* Assume that the leading constant is ==, *) |
738 fun restrict_prover ctxt thm = |
739 fun restrict_prover ctxt thm = |
739 let val dummy = say "restrict_prover:" |
740 let val dummy = say "restrict_prover:" |
740 val cntxt = rev (Simplifier.prems_of ctxt) |
741 val cntxt = rev (Simplifier.prems_of ctxt) |
741 val dummy = print_thms ctxt "cntxt:" cntxt |
742 val dummy = print_thms ctxt "cntxt:" cntxt |
742 val thy = Thm.theory_of_thm thm |
743 val thy = Thm.theory_of_thm thm |
743 val Const("==>",_) $ (Const(@{const_name Trueprop},_) $ A) $ _ = Thm.prop_of thm |
744 val Const(@{const_name Pure.imp},_) $ (Const(@{const_name Trueprop},_) $ A) $ _ = |
|
745 Thm.prop_of thm |
744 fun genl tm = let val vlist = subtract (op aconv) globals |
746 fun genl tm = let val vlist = subtract (op aconv) globals |
745 (Misc_Legacy.add_term_frees(tm,[])) |
747 (Misc_Legacy.add_term_frees(tm,[])) |
746 in fold_rev Forall vlist tm |
748 in fold_rev Forall vlist tm |
747 end |
749 end |
748 (*-------------------------------------------------------------- |
750 (*-------------------------------------------------------------- |