653 fun lift_procedure_tac ctxt rthm = |
653 fun lift_procedure_tac ctxt rthm = |
654 Object_Logic.full_atomize_tac |
654 Object_Logic.full_atomize_tac |
655 THEN' gen_frees_tac ctxt |
655 THEN' gen_frees_tac ctxt |
656 THEN' SUBGOAL (fn (goal, i) => |
656 THEN' SUBGOAL (fn (goal, i) => |
657 let |
657 let |
658 val rthm' = atomize_thm rthm |
658 (* full_atomize_tac contracts eta redexes, |
|
659 so we do it also in the original theorem *) |
|
660 val rthm' = |
|
661 rthm |> Drule.eta_contraction_rule |
|
662 |> Thm.forall_intr_frees |
|
663 |> atomize_thm |
|
664 |
659 val rule = procedure_inst ctxt (prop_of rthm') goal |
665 val rule = procedure_inst ctxt (prop_of rthm') goal |
660 in |
666 in |
661 (rtac rule THEN' rtac rthm') i |
667 (rtac rule THEN' rtac rthm') i |
662 end) |
668 end) |
663 |
669 |
677 (* automated lifting with pre-simplification of the theorems; |
683 (* automated lifting with pre-simplification of the theorems; |
678 for internal usage *) |
684 for internal usage *) |
679 fun lifted ctxt qtys simps rthm = |
685 fun lifted ctxt qtys simps rthm = |
680 let |
686 let |
681 val ss = (mk_minimal_ss ctxt) addsimps simps |
687 val ss = (mk_minimal_ss ctxt) addsimps simps |
682 |
688 val rthm' = asm_full_simplify ss rthm |
683 (* When the theorem is atomized, eta redexes are contracted, |
689 |
684 so we do it both in the original theorem *) |
|
685 val rthm' = |
|
686 rthm |
|
687 |> asm_full_simplify ss |
|
688 |> Drule.eta_contraction_rule |
|
689 val ((_, [rthm'']), ctxt') = Variable.import true [rthm'] ctxt |
690 val ((_, [rthm'']), ctxt') = Variable.import true [rthm'] ctxt |
690 val goal = derive_qtrm ctxt' qtys (prop_of rthm'') |
691 val goal = derive_qtrm ctxt' qtys (prop_of rthm'') |
691 in |
692 in |
692 Goal.prove ctxt' [] [] goal |
693 Goal.prove ctxt' [] [] goal |
693 (K ((asm_full_simp_tac ss THEN' lift_single_tac ctxt' rthm') 1)) |
694 (K (HEADGOAL (asm_full_simp_tac ss THEN' lift_single_tac ctxt' rthm''))) |
694 |> singleton (ProofContext.export ctxt' ctxt) |
695 |> singleton (ProofContext.export ctxt' ctxt) |
695 end |
696 end |
696 |
697 |
697 |
698 |
698 (* lifting as an attribute *) |
699 (* lifting as an attribute *) |