558 val (tye',maxi') = Type.unify (#tsig(Sign.rep_sg sign')) maxi tye (T,U) |
558 val (tye',maxi') = Type.unify (#tsig(Sign.rep_sg sign')) maxi tye (T,U) |
559 handle Type.TUNIFY => raise TYPE("add_types", [T,U], [t,u]) |
559 handle Type.TUNIFY => raise TYPE("add_types", [T,U], [t,u]) |
560 in (sign', tye', maxi') end; |
560 in (sign', tye', maxi') end; |
561 in |
561 in |
562 fun cterm_instantiate ctpairs0 th = |
562 fun cterm_instantiate ctpairs0 th = |
563 let val (sign,tye,_) = foldr add_types (ctpairs0, (#sign(rep_thm th),[],0)) |
563 let val (sign,tye,_) = foldr add_types (ctpairs0, (#sign(rep_thm th), Vartab.empty, 0)) |
564 val tsig = #tsig(Sign.rep_sg sign); |
564 val tsig = #tsig(Sign.rep_sg sign); |
565 fun instT(ct,cu) = let val inst = subst_TVars tye |
565 fun instT(ct,cu) = let val inst = subst_TVars_Vartab tye |
566 in (cterm_fun inst ct, cterm_fun inst cu) end |
566 in (cterm_fun inst ct, cterm_fun inst cu) end |
567 fun ctyp2 (ix,T) = (ix, ctyp_of sign T) |
567 fun ctyp2 (ix,T) = (ix, ctyp_of sign T) |
568 in instantiate (map ctyp2 tye, map instT ctpairs0) th end |
568 in instantiate (map ctyp2 (Vartab.dest tye), map instT ctpairs0) th end |
569 handle TERM _ => |
569 handle TERM _ => |
570 raise THM("cterm_instantiate: incompatible signatures",0,[th]) |
570 raise THM("cterm_instantiate: incompatible signatures",0,[th]) |
571 | TYPE (msg, _, _) => raise THM(msg, 0, [th]) |
571 | TYPE (msg, _, _) => raise THM(msg, 0, [th]) |
572 end; |
572 end; |
573 |
573 |