163 |
163 |
164 (*Generalization over a list of variables*) |
164 (*Generalization over a list of variables*) |
165 val forall_intr_list = fold_rev Thm.forall_intr; |
165 val forall_intr_list = fold_rev Thm.forall_intr; |
166 |
166 |
167 (*Generalization over Vars -- canonical order*) |
167 (*Generalization over Vars -- canonical order*) |
168 fun forall_intr_vars th = fold Thm.forall_intr (Thm.add_vars th []) th; |
168 fun forall_intr_vars th = |
|
169 let |
|
170 val vs = |
|
171 build (th |> Thm.fold_atomic_cterms {hyps = false} (fn a => |
|
172 is_Var (Thm.term_of a) ? insert (op aconvc) a)); |
|
173 in fold Thm.forall_intr vs th end; |
169 |
174 |
170 fun outer_params t = |
175 fun outer_params t = |
171 let val vs = Term.strip_all_vars t |
176 let val vs = Term.strip_all_vars t |
172 in Name.variant_list [] (map (Name.clean o #1) vs) ~~ map #2 vs end; |
177 in Name.variant_list [] (map (Name.clean o #1) vs) ~~ map #2 vs end; |
173 |
178 |
216 | zero_var_indexes_list ths = |
221 | zero_var_indexes_list ths = |
217 let |
222 let |
218 val (instT, inst) = |
223 val (instT, inst) = |
219 Term_Subst.zero_var_indexes_inst Name.context (map Thm.full_prop_of ths); |
224 Term_Subst.zero_var_indexes_inst Name.context (map Thm.full_prop_of ths); |
220 |
225 |
221 val tvars = fold Thm.add_tvars ths []; |
226 val tvars = fold Thm.add_tvars ths Term_Subst.TVars.empty; |
222 fun the_tvar v = the (find_first (fn cT => v = dest_TVar (Thm.typ_of cT)) tvars); |
227 val the_tvar = the o Term_Subst.TVars.lookup tvars; |
223 val instT' = |
228 val instT' = |
224 build (instT |> Term_Subst.TVars.fold (fn (v, TVar (b, _)) => |
229 build (instT |> Term_Subst.TVars.fold (fn (v, TVar (b, _)) => |
225 cons (v, Thm.rename_tvar b (the_tvar v)))); |
230 cons (v, Thm.rename_tvar b (the_tvar v)))); |
226 |
231 |
227 val vars = fold (Thm.add_vars o Thm.instantiate (instT', [])) ths []; |
232 val vars = fold (Thm.add_vars o Thm.instantiate (instT', [])) ths Term_Subst.Vars.empty; |
228 fun the_var v = the (find_first (fn ct => v = dest_Var (Thm.term_of ct)) vars); |
233 val the_var = the o Term_Subst.Vars.lookup vars; |
229 val inst' = |
234 val inst' = |
230 build (inst |> Term_Subst.Vars.fold (fn (v, Var (b, _)) => |
235 build (inst |> Term_Subst.Vars.fold (fn (v, Var (b, _)) => |
231 cons (v, Thm.var (b, Thm.ctyp_of_cterm (the_var v))))); |
236 cons (v, Thm.var (b, Thm.ctyp_of_cterm (the_var v))))); |
232 in map (Thm.adjust_maxidx_thm ~1 o Thm.instantiate (instT', inst')) ths end; |
237 in map (Thm.adjust_maxidx_thm ~1 o Thm.instantiate (instT', inst')) ths end; |
233 |
238 |