52 val dest_term: term -> term |
52 val dest_term: term -> term |
53 val occs: term * term -> bool |
53 val occs: term * term -> bool |
54 val close_form: term -> term |
54 val close_form: term -> term |
55 val combound: term * int * int -> term |
55 val combound: term * int * int -> term |
56 val rlist_abs: (string * typ) list * term -> term |
56 val rlist_abs: (string * typ) list * term -> term |
|
57 val incr_tvar_same: int -> typ Same.operation |
|
58 val incr_tvar: int -> typ -> typ |
57 val incr_indexes: typ list * int -> term -> term |
59 val incr_indexes: typ list * int -> term -> term |
58 val incr_tvar: int -> typ -> typ |
|
59 val lift_abs: int -> term -> term -> term |
60 val lift_abs: int -> term -> term -> term |
60 val lift_all: int -> term -> term -> term |
61 val lift_all: int -> term -> term -> term |
61 val strip_assums_hyp: term -> term list |
62 val strip_assums_hyp: term -> term list |
62 val strip_assums_concl: term -> term |
63 val strip_assums_concl: term -> term |
63 val strip_params: term -> (string * typ) list |
64 val strip_params: term -> (string * typ) list |
301 |
302 |
302 (* ([xn,...,x1], t) ======> (x1,...,xn)t *) |
303 (* ([xn,...,x1], t) ======> (x1,...,xn)t *) |
303 fun rlist_abs ([], body) = body |
304 fun rlist_abs ([], body) = body |
304 | rlist_abs ((a,T)::pairs, body) = rlist_abs(pairs, Abs(a, T, body)); |
305 | rlist_abs ((a,T)::pairs, body) = rlist_abs(pairs, Abs(a, T, body)); |
305 |
306 |
306 |
307 fun incr_tvar_same k = Term_Subst.map_atypsT_same |
307 fun incrT k = Term_Subst.map_atypsT_same |
|
308 (fn TVar ((a, i), S) => TVar ((a, i + k), S) |
308 (fn TVar ((a, i), S) => TVar ((a, i + k), S) |
309 | _ => raise Same.SAME); |
309 | _ => raise Same.SAME); |
|
310 |
|
311 fun incr_tvar 0 T = T |
|
312 | incr_tvar k T = incr_tvar_same k T handle Same.SAME => T; |
310 |
313 |
311 (*For all variables in the term, increment indexnames and lift over the Us |
314 (*For all variables in the term, increment indexnames and lift over the Us |
312 result is ?Gidx(B.(lev+n-1),...,B.lev) where lev is abstraction level *) |
315 result is ?Gidx(B.(lev+n-1),...,B.lev) where lev is abstraction level *) |
313 fun incr_indexes ([], 0) t = t |
316 fun incr_indexes ([], 0) t = t |
314 | incr_indexes (Ts, k) t = |
317 | incr_indexes (Ts, k) t = |
315 let |
318 let |
316 val n = length Ts; |
319 val n = length Ts; |
317 val incrT = if k = 0 then I else incrT k; |
320 val incrT = if k = 0 then I else incr_tvar_same k; |
318 |
321 |
319 fun incr lev (Var ((x, i), T)) = |
322 fun incr lev (Var ((x, i), T)) = |
320 combound (Var ((x, i + k), Ts ---> Same.commit incrT T), lev, n) |
323 combound (Var ((x, i + k), Ts ---> Same.commit incrT T), lev, n) |
321 | incr lev (Abs (x, T, body)) = |
324 | incr lev (Abs (x, T, body)) = |
322 (Abs (x, incrT T, incr (lev + 1) body handle Same.SAME => body) |
325 (Abs (x, incrT T, incr (lev + 1) body handle Same.SAME => body) |
326 handle Same.SAME => t $ incr lev u) |
329 handle Same.SAME => t $ incr lev u) |
327 | incr _ (Const (c, T)) = Const (c, incrT T) |
330 | incr _ (Const (c, T)) = Const (c, incrT T) |
328 | incr _ (Free (x, T)) = Free (x, incrT T) |
331 | incr _ (Free (x, T)) = Free (x, incrT T) |
329 | incr _ (t as Bound _) = t; |
332 | incr _ (t as Bound _) = t; |
330 in incr 0 t handle Same.SAME => t end; |
333 in incr 0 t handle Same.SAME => t end; |
331 |
|
332 fun incr_tvar 0 T = T |
|
333 | incr_tvar k T = incrT k T handle Same.SAME => T; |
|
334 |
334 |
335 |
335 |
336 (* Lifting functions from subgoal and increment: |
336 (* Lifting functions from subgoal and increment: |
337 lift_abs operates on terms |
337 lift_abs operates on terms |
338 lift_all operates on propositions *) |
338 lift_all operates on propositions *) |