18 val forall_intr_list: cterm list -> thm -> thm |
18 val forall_intr_list: cterm list -> thm -> thm |
19 val forall_intr_vars: thm -> thm |
19 val forall_intr_vars: thm -> thm |
20 val forall_elim_list: cterm list -> thm -> thm |
20 val forall_elim_list: cterm list -> thm -> thm |
21 val gen_all: thm -> thm |
21 val gen_all: thm -> thm |
22 val lift_all: cterm -> thm -> thm |
22 val lift_all: cterm -> thm -> thm |
23 val legacy_freeze_thaw: thm -> thm * (thm -> thm) |
|
24 val legacy_freeze_thaw_robust: thm -> thm * (int -> thm -> thm) |
|
25 val implies_elim_list: thm -> thm list -> thm |
23 val implies_elim_list: thm -> thm list -> thm |
26 val implies_intr_list: cterm list -> thm -> thm |
24 val implies_intr_list: cterm list -> thm -> thm |
27 val instantiate_normalize: (ctyp * ctyp) list * (cterm * cterm) list -> thm -> thm |
25 val instantiate_normalize: (ctyp * ctyp) list * (cterm * cterm) list -> thm -> thm |
28 val zero_var_indexes_list: thm list -> thm list |
26 val zero_var_indexes_list: thm list -> thm list |
29 val zero_var_indexes: thm -> thm |
27 val zero_var_indexes: thm -> thm |
297 flexflex_unique |
295 flexflex_unique |
298 #> export_without_context_open |
296 #> export_without_context_open |
299 #> Thm.close_derivation; |
297 #> Thm.close_derivation; |
300 |
298 |
301 |
299 |
302 (*Convert all Vars in a theorem to Frees. Also return a function for |
|
303 reversing that operation. DOES NOT WORK FOR TYPE VARIABLES.*) |
|
304 |
|
305 fun legacy_freeze_thaw_robust th = |
|
306 let val fth = Thm.legacy_freezeT th |
|
307 val thy = Thm.theory_of_thm fth |
|
308 in |
|
309 case Thm.fold_terms Term.add_vars fth [] of |
|
310 [] => (fth, fn i => fn x => x) (*No vars: nothing to do!*) |
|
311 | vars => |
|
312 let fun newName (ix,_) = (ix, legacy_gensym (string_of_indexname ix)) |
|
313 val alist = map newName vars |
|
314 fun mk_inst (v,T) = |
|
315 (cterm_of thy (Var(v,T)), |
|
316 cterm_of thy (Free(((the o AList.lookup (op =) alist) v), T))) |
|
317 val insts = map mk_inst vars |
|
318 fun thaw i th' = (*i is non-negative increment for Var indexes*) |
|
319 th' |> forall_intr_list (map #2 insts) |
|
320 |> forall_elim_list (map (Thm.incr_indexes_cterm i o #1) insts) |
|
321 in (Thm.instantiate ([],insts) fth, thaw) end |
|
322 end; |
|
323 |
|
324 (*Basic version of the function above. No option to rename Vars apart in thaw. |
|
325 The Frees created from Vars have nice names.*) |
|
326 fun legacy_freeze_thaw th = |
|
327 let val fth = Thm.legacy_freezeT th |
|
328 val thy = Thm.theory_of_thm fth |
|
329 in |
|
330 case Thm.fold_terms Term.add_vars fth [] of |
|
331 [] => (fth, fn x => x) |
|
332 | vars => |
|
333 let fun newName (ix, _) (pairs, used) = |
|
334 let val v = singleton (Name.variant_list used) (string_of_indexname ix) |
|
335 in ((ix,v)::pairs, v::used) end; |
|
336 val (alist, _) = |
|
337 fold_rev newName vars ([], Thm.fold_terms Term.add_free_names fth []) |
|
338 fun mk_inst (v, T) = |
|
339 (cterm_of thy (Var(v,T)), |
|
340 cterm_of thy (Free(((the o AList.lookup (op =) alist) v), T))) |
|
341 val insts = map mk_inst vars |
|
342 fun thaw th' = |
|
343 th' |> forall_intr_list (map #2 insts) |
|
344 |> forall_elim_list (map #1 insts) |
|
345 in (Thm.instantiate ([],insts) fth, thaw) end |
|
346 end; |
|
347 |
|
348 (*Rotates a rule's premises to the left by k*) |
300 (*Rotates a rule's premises to the left by k*) |
349 fun rotate_prems 0 = I |
301 fun rotate_prems 0 = I |
350 | rotate_prems k = Thm.permute_prems 0 k; |
302 | rotate_prems k = Thm.permute_prems 0 k; |
351 |
303 |
352 fun with_subgoal i f = rotate_prems (i - 1) #> f #> rotate_prems (1 - i); |
304 fun with_subgoal i f = rotate_prems (i - 1) #> f #> rotate_prems (1 - i); |