261 val of_local = gen_of I; |
261 val of_local = gen_of I; |
262 |
262 |
263 |
263 |
264 (* rename_abs *) |
264 (* rename_abs *) |
265 |
265 |
266 fun rename [] t = ([], t) |
|
267 | rename (x' :: xs) (Abs (x, T, t)) = |
|
268 let val (xs', t') = rename xs t |
|
269 in (xs', Abs (if_none x' x, T, t')) end |
|
270 | rename xs (t $ u) = |
|
271 let |
|
272 val (xs', t') = rename xs t; |
|
273 val (xs'', u') = rename xs' u |
|
274 in (xs'', t' $ u') end |
|
275 | rename xs t = (xs, t); |
|
276 |
|
277 fun rename_abs_thm xs (ctxt, thm) = |
|
278 let val {sign, prop, ...} = rep_thm thm; |
|
279 in case rename xs prop of |
|
280 ([], prop') => (ctxt, equal_elim (reflexive (cterm_of sign prop')) thm) |
|
281 | _ => error "More names than abstractions in theorem" |
|
282 end; |
|
283 |
|
284 fun rename_abs src = syntax |
266 fun rename_abs src = syntax |
285 (Scan.lift (Scan.repeat Args.name_dummy >> rename_abs_thm)) src; |
267 (Scan.lift (Scan.repeat Args.name_dummy >> (apsnd o Drule.rename_bvars'))) src; |
286 |
268 |
287 |
269 |
288 (* unfold / fold definitions *) |
270 (* unfold / fold definitions *) |
289 |
271 |
290 fun gen_rewrite rew defs (x, thm) = (x, rew defs thm); |
272 fun gen_rewrite rew defs (x, thm) = (x, rew defs thm); |