691 val rules = extra_rules @ get_transfer_raw ctxt |
691 val rules = extra_rules @ get_transfer_raw ctxt |
692 val eq_rules = get_relator_eq_raw ctxt |
692 val eq_rules = get_relator_eq_raw ctxt |
693 val err_msg = "Transfer failed to convert goal to an object-logic formula" |
693 val err_msg = "Transfer failed to convert goal to an object-logic formula" |
694 val pre_simps = @{thms transfer_forall_eq transfer_implies_eq} |
694 val pre_simps = @{thms transfer_forall_eq transfer_implies_eq} |
695 val thm1 = Drule.forall_intr_vars thm |
695 val thm1 = Drule.forall_intr_vars thm |
696 val instT = rev (Term.add_tvars (Thm.full_prop_of thm1) []) |
696 val instT = |
697 |> map (fn v as ((a, _), S) => (v, TFree (a, S))) |
697 rev (Term.add_tvars (Thm.full_prop_of thm1) []) |
|
698 |> map (fn v as ((a, _), S) => (v, Thm.ctyp_of ctxt (TFree (a, S)))) |
698 val thm2 = thm1 |
699 val thm2 = thm1 |
699 |> Thm.certify_instantiate ctxt (instT, []) |
700 |> Thm.instantiate (instT, []) |
700 |> Raw_Simplifier.rewrite_rule ctxt pre_simps |
701 |> Raw_Simplifier.rewrite_rule ctxt pre_simps |
701 val ctxt' = Variable.declare_names (Thm.full_prop_of thm2) ctxt |
702 val ctxt' = Variable.declare_names (Thm.full_prop_of thm2) ctxt |
702 val t = HOLogic.dest_Trueprop (Thm.concl_of thm2) |
703 val t = HOLogic.dest_Trueprop (Thm.concl_of thm2) |
703 val rule = transfer_rule_of_lhs ctxt' t |
704 val rule = transfer_rule_of_lhs ctxt' t |
704 val tac = |
705 val tac = |
707 THEN_ALL_NEW |
708 THEN_ALL_NEW |
708 (SOLVED' (REPEAT_ALL_NEW (resolve_tac ctxt' rules) |
709 (SOLVED' (REPEAT_ALL_NEW (resolve_tac ctxt' rules) |
709 THEN_ALL_NEW (DETERM o eq_rules_tac ctxt' eq_rules)))) 1 |
710 THEN_ALL_NEW (DETERM o eq_rules_tac ctxt' eq_rules)))) 1 |
710 handle TERM (_, ts) => raise TERM (err_msg, ts) |
711 handle TERM (_, ts) => raise TERM (err_msg, ts) |
711 val thm3 = Goal.prove_internal ctxt' [] @{cpat "Trueprop ?P"} (K tac) |
712 val thm3 = Goal.prove_internal ctxt' [] @{cpat "Trueprop ?P"} (K tac) |
712 val tnames = map (fst o dest_TFree o snd) instT |
713 val tnames = map (fst o dest_TFree o Thm.typ_of o snd) instT |
713 in |
714 in |
714 thm3 |
715 thm3 |
715 |> Raw_Simplifier.rewrite_rule ctxt' post_simps |
716 |> Raw_Simplifier.rewrite_rule ctxt' post_simps |
716 |> Simplifier.norm_hhf ctxt' |
717 |> Simplifier.norm_hhf ctxt' |
717 |> Drule.generalize (tnames, []) |
718 |> Drule.generalize (tnames, []) |
727 val rules = extra_rules @ get_transfer_raw ctxt |
728 val rules = extra_rules @ get_transfer_raw ctxt |
728 val eq_rules = get_relator_eq_raw ctxt |
729 val eq_rules = get_relator_eq_raw ctxt |
729 val err_msg = "Transfer failed to convert goal to an object-logic formula" |
730 val err_msg = "Transfer failed to convert goal to an object-logic formula" |
730 val pre_simps = @{thms transfer_forall_eq transfer_implies_eq} |
731 val pre_simps = @{thms transfer_forall_eq transfer_implies_eq} |
731 val thm1 = Drule.forall_intr_vars thm |
732 val thm1 = Drule.forall_intr_vars thm |
732 val instT = rev (Term.add_tvars (Thm.full_prop_of thm1) []) |
733 val instT = |
733 |> map (fn v as ((a, _), S) => (v, TFree (a, S))) |
734 rev (Term.add_tvars (Thm.full_prop_of thm1) []) |
|
735 |> map (fn v as ((a, _), S) => (v, Thm.ctyp_of ctxt (TFree (a, S)))) |
734 val thm2 = thm1 |
736 val thm2 = thm1 |
735 |> Thm.certify_instantiate ctxt (instT, []) |
737 |> Thm.instantiate (instT, []) |
736 |> Raw_Simplifier.rewrite_rule ctxt pre_simps |
738 |> Raw_Simplifier.rewrite_rule ctxt pre_simps |
737 val ctxt' = Variable.declare_names (Thm.full_prop_of thm2) ctxt |
739 val ctxt' = Variable.declare_names (Thm.full_prop_of thm2) ctxt |
738 val t = HOLogic.dest_Trueprop (Thm.concl_of thm2) |
740 val t = HOLogic.dest_Trueprop (Thm.concl_of thm2) |
739 val rule = transfer_rule_of_term ctxt' true t |
741 val rule = transfer_rule_of_term ctxt' true t |
740 val tac = |
742 val tac = |
743 THEN_ALL_NEW |
745 THEN_ALL_NEW |
744 (SOLVED' (REPEAT_ALL_NEW (resolve_tac ctxt' rules) |
746 (SOLVED' (REPEAT_ALL_NEW (resolve_tac ctxt' rules) |
745 THEN_ALL_NEW (DETERM o eq_rules_tac ctxt' eq_rules)))) 1 |
747 THEN_ALL_NEW (DETERM o eq_rules_tac ctxt' eq_rules)))) 1 |
746 handle TERM (_, ts) => raise TERM (err_msg, ts) |
748 handle TERM (_, ts) => raise TERM (err_msg, ts) |
747 val thm3 = Goal.prove_internal ctxt' [] @{cpat "Trueprop ?P"} (K tac) |
749 val thm3 = Goal.prove_internal ctxt' [] @{cpat "Trueprop ?P"} (K tac) |
748 val tnames = map (fst o dest_TFree o snd) instT |
750 val tnames = map (fst o dest_TFree o Thm.typ_of o snd) instT |
749 in |
751 in |
750 thm3 |
752 thm3 |
751 |> Raw_Simplifier.rewrite_rule ctxt' post_simps |
753 |> Raw_Simplifier.rewrite_rule ctxt' post_simps |
752 |> Simplifier.norm_hhf ctxt' |
754 |> Simplifier.norm_hhf ctxt' |
753 |> Drule.generalize (tnames, []) |
755 |> Drule.generalize (tnames, []) |