63 val names_ctxt = ctxt |
63 val names_ctxt = ctxt |
64 |> fold Variable.declare_names vars |
64 |> fold Variable.declare_names vars |
65 |> fold Variable.declare_thm (raw_thm :: prems); |
65 |> fold Variable.declare_thm (raw_thm :: prems); |
66 val thm_concl = Thm.cprop_of raw_thm |> strip_imp_concl; |
66 val thm_concl = Thm.cprop_of raw_thm |> strip_imp_concl; |
67 val (rhoTs, rhots) = Thm.match (thm_concl, concl) |
67 val (rhoTs, rhots) = Thm.match (thm_concl, concl) |
68 |>> map (pairself typ_of) |
68 |>> map (apply2 typ_of) |
69 ||> map (pairself term_of); |
69 ||> map (apply2 term_of); |
70 val xs = hd (Thm.prems_of raw_thm) |> HOLogic.dest_Trueprop |> strip_comb |> snd |
70 val xs = hd (Thm.prems_of raw_thm) |> HOLogic.dest_Trueprop |> strip_comb |> snd |
71 |> map (subst_atomic_types rhoTs); |
71 |> map (subst_atomic_types rhoTs); |
72 val raw_eqs = map (fn x => (x, AList.lookup op aconv rhots x |> the)) xs; |
72 val raw_eqs = map (fn x => (x, AList.lookup op aconv rhots x |> the)) xs; |
73 val ((names, ctxt), Ts) = map_split (apfst fst o dest_Var o fst) raw_eqs |
73 val ((names, ctxt), Ts) = map_split (apfst fst o dest_Var o fst) raw_eqs |
74 |>> (fn names => Variable.variant_fixes names names_ctxt) ; |
74 |>> (fn names => Variable.variant_fixes names names_ctxt) ; |