114 (* result *) |
114 (* result *) |
115 |
115 |
116 val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars; |
116 val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars; |
117 val inst_vars = map_filter (make_inst inst2) vars2; |
117 val inst_vars = map_filter (make_inst inst2) vars2; |
118 in |
118 in |
119 (map (apply2 (Thm.ctyp_of thy)) inst_tvars, |
119 (map (apply2 (Thm.global_ctyp_of thy)) inst_tvars, |
120 map (apply2 (Thm.cterm_of thy)) inst_vars) |
120 map (apply2 (Thm.global_cterm_of thy)) inst_vars) |
121 end; |
121 end; |
122 |
122 |
123 fun where_rule ctxt mixed_insts fixes thm = |
123 fun where_rule ctxt mixed_insts fixes thm = |
124 let |
124 let |
125 val ctxt' = ctxt |
125 val ctxt' = ctxt |
248 val envT' = map (fn (ixn, T) => |
248 val envT' = map (fn (ixn, T) => |
249 (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env; |
249 (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env; |
250 val cenv = |
250 val cenv = |
251 map |
251 map |
252 (fn (xi, t) => |
252 (fn (xi, t) => |
253 apply2 (Thm.cterm_of thy) (Var (xi, fastype_of t), t)) |
253 apply2 (Thm.global_cterm_of thy) (Var (xi, fastype_of t), t)) |
254 (distinct |
254 (distinct |
255 (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) |
255 (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) |
256 (xis ~~ ts)); |
256 (xis ~~ ts)); |
257 (* Lift and instantiate rule *) |
257 (* Lift and instantiate rule *) |
258 val maxidx = Thm.maxidx_of st; |
258 val maxidx = Thm.maxidx_of st; |
262 Var((a, j+inc), paramTs ---> Logic.incr_tvar inc T) |
262 Var((a, j+inc), paramTs ---> Logic.incr_tvar inc T) |
263 | liftvar t = raise TERM("Variable expected", [t]); |
263 | liftvar t = raise TERM("Variable expected", [t]); |
264 fun liftterm t = |
264 fun liftterm t = |
265 fold_rev absfree (param_names ~~ paramTs) (Logic.incr_indexes (paramTs, inc) t); |
265 fold_rev absfree (param_names ~~ paramTs) (Logic.incr_indexes (paramTs, inc) t); |
266 fun liftpair (cv, ct) = (cterm_fun liftvar cv, cterm_fun liftterm ct); |
266 fun liftpair (cv, ct) = (cterm_fun liftvar cv, cterm_fun liftterm ct); |
267 val lifttvar = apply2 (Thm.ctyp_of thy o Logic.incr_tvar inc); |
267 val lifttvar = apply2 (Thm.global_ctyp_of thy o Logic.incr_tvar inc); |
268 val rule = Drule.instantiate_normalize |
268 val rule = Drule.instantiate_normalize |
269 (map lifttvar envT', map liftpair cenv) |
269 (map lifttvar envT', map liftpair cenv) |
270 (Thm.lift_rule cgoal thm) |
270 (Thm.lift_rule cgoal thm) |
271 in |
271 in |
272 compose_tac ctxt' (bires_flag, rule, Thm.nprems_of thm) i |
272 compose_tac ctxt' (bires_flag, rule, Thm.nprems_of thm) i |
281 |
281 |
282 fun make_elim_preserve ctxt rl = |
282 fun make_elim_preserve ctxt rl = |
283 let |
283 let |
284 val thy = Thm.theory_of_thm rl; |
284 val thy = Thm.theory_of_thm rl; |
285 val maxidx = Thm.maxidx_of rl; |
285 val maxidx = Thm.maxidx_of rl; |
286 fun cvar xi = Thm.cterm_of thy (Var (xi, propT)); |
286 fun cvar xi = Thm.global_cterm_of thy (Var (xi, propT)); |
287 val revcut_rl' = |
287 val revcut_rl' = |
288 Drule.instantiate_normalize ([], [(cvar ("V", 0), cvar ("V", maxidx + 1)), |
288 Drule.instantiate_normalize ([], [(cvar ("V", 0), cvar ("V", maxidx + 1)), |
289 (cvar ("W", 0), cvar ("W", maxidx + 1))]) Drule.revcut_rl; |
289 (cvar ("W", 0), cvar ("W", maxidx + 1))]) Drule.revcut_rl; |
290 in |
290 in |
291 (case Seq.list_of |
291 (case Seq.list_of |