212 val (instT, inst) = |
212 val (instT, inst) = |
213 Term_Subst.zero_var_indexes_inst Name.context (map Thm.full_prop_of ths); |
213 Term_Subst.zero_var_indexes_inst Name.context (map Thm.full_prop_of ths); |
214 |
214 |
215 val tvars = fold Thm.add_tvars ths []; |
215 val tvars = fold Thm.add_tvars ths []; |
216 fun the_tvar v = the (find_first (fn cT => v = dest_TVar (Thm.typ_of cT)) tvars); |
216 fun the_tvar v = the (find_first (fn cT => v = dest_TVar (Thm.typ_of cT)) tvars); |
217 val instT' = map (fn (v, TVar (b, _)) => (v, Thm.rename_tvar b (the_tvar v))) instT; |
217 val instT' = |
|
218 (instT, []) |-> Term_Subst.TVars.fold (fn (v, TVar (b, _)) => |
|
219 cons (v, Thm.rename_tvar b (the_tvar v))); |
218 |
220 |
219 val vars = fold (Thm.add_vars o Thm.instantiate (instT', [])) ths []; |
221 val vars = fold (Thm.add_vars o Thm.instantiate (instT', [])) ths []; |
220 fun the_var v = the (find_first (fn ct => v = dest_Var (Thm.term_of ct)) vars); |
222 fun the_var v = the (find_first (fn ct => v = dest_Var (Thm.term_of ct)) vars); |
221 val inst' = map (fn (v, Var (b, _)) => (v, Thm.var (b, Thm.ctyp_of_cterm (the_var v)))) inst; |
223 val inst' = |
|
224 (inst, []) |-> Term_Subst.Vars.fold (fn (v, Var (b, _)) => |
|
225 cons (v, Thm.var (b, Thm.ctyp_of_cterm (the_var v)))); |
222 in map (Thm.adjust_maxidx_thm ~1 o Thm.instantiate (instT', inst')) ths end; |
226 in map (Thm.adjust_maxidx_thm ~1 o Thm.instantiate (instT', inst')) ths end; |
223 |
227 |
224 val zero_var_indexes = singleton zero_var_indexes_list; |
228 val zero_var_indexes = singleton zero_var_indexes_list; |
225 |
229 |
226 |
230 |