src/Pure/Tools/rule_insts.ML
changeset 59058 a78612c67ec0
parent 58963 26bf09b95dda
child 59498 50b60f501b05
equal deleted inserted replaced
59057:5b649fb2f2e1 59058:a78612c67ec0
   116     (* result *)
   116     (* result *)
   117 
   117 
   118     val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars;
   118     val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars;
   119     val inst_vars = map_filter (make_inst inst2) vars2;
   119     val inst_vars = map_filter (make_inst inst2) vars2;
   120   in
   120   in
   121     (map (pairself certT) inst_tvars, map (pairself cert) inst_vars)
   121     (map (apply2 certT) inst_tvars, map (apply2 cert) inst_vars)
   122   end;
   122   end;
   123 
   123 
   124 fun where_rule ctxt mixed_insts fixes thm =
   124 fun where_rule ctxt mixed_insts fixes thm =
   125   let
   125   let
   126     val ctxt' = ctxt
   126     val ctxt' = ctxt
   249         val envT' = map (fn (ixn, T) =>
   249         val envT' = map (fn (ixn, T) =>
   250           (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env;
   250           (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env;
   251         val cenv =
   251         val cenv =
   252           map
   252           map
   253             (fn (xi, t) =>
   253             (fn (xi, t) =>
   254               pairself (Thm.cterm_of thy) (Var (xi, fastype_of t), t))
   254               apply2 (Thm.cterm_of thy) (Var (xi, fastype_of t), t))
   255             (distinct
   255             (distinct
   256               (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2)
   256               (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2)
   257               (xis ~~ ts));
   257               (xis ~~ ts));
   258         (* Lift and instantiate rule *)
   258         (* Lift and instantiate rule *)
   259         val maxidx = Thm.maxidx_of st;
   259         val maxidx = Thm.maxidx_of st;
   263               Var((a, j+inc), paramTs ---> Logic.incr_tvar inc T)
   263               Var((a, j+inc), paramTs ---> Logic.incr_tvar inc T)
   264           | liftvar t = raise TERM("Variable expected", [t]);
   264           | liftvar t = raise TERM("Variable expected", [t]);
   265         fun liftterm t =
   265         fun liftterm t =
   266           fold_rev absfree (param_names ~~ paramTs) (Logic.incr_indexes (paramTs, inc) t);
   266           fold_rev absfree (param_names ~~ paramTs) (Logic.incr_indexes (paramTs, inc) t);
   267         fun liftpair (cv, ct) = (cterm_fun liftvar cv, cterm_fun liftterm ct);
   267         fun liftpair (cv, ct) = (cterm_fun liftvar cv, cterm_fun liftterm ct);
   268         val lifttvar = pairself (ctyp_of thy o Logic.incr_tvar inc);
   268         val lifttvar = apply2 (ctyp_of thy o Logic.incr_tvar inc);
   269         val rule = Drule.instantiate_normalize
   269         val rule = Drule.instantiate_normalize
   270               (map lifttvar envT', map liftpair cenv)
   270               (map lifttvar envT', map liftpair cenv)
   271               (Thm.lift_rule cgoal thm)
   271               (Thm.lift_rule cgoal thm)
   272       in
   272       in
   273         compose_tac ctxt' (bires_flag, rule, nprems_of thm) i
   273         compose_tac ctxt' (bires_flag, rule, nprems_of thm) i