src/Pure/Tools/rule_insts.ML
changeset 74220 c49134ee16c1
parent 67147 dea94b1aabc3
child 74229 76ac4dbb0a22
equal deleted inserted replaced
74219:1d25be2353e1 74220:c49134ee16c1
   117       |> fold (Variable.declare_internal o Logic.mk_type o TVar) tvars
   117       |> fold (Variable.declare_internal o Logic.mk_type o TVar) tvars
   118       |> fold (Variable.declare_internal o Var) vars
   118       |> fold (Variable.declare_internal o Var) vars
   119       |> Proof_Context.add_fixes_cmd raw_fixes;
   119       |> Proof_Context.add_fixes_cmd raw_fixes;
   120 
   120 
   121     (*explicit type instantiations*)
   121     (*explicit type instantiations*)
   122     val instT1 = Term_Subst.instantiateT (map (read_type ctxt1 tvars) type_insts);
   122     val instT1 =
       
   123       Term_Subst.instantiateT (Term_Subst.TVars.table (map (read_type ctxt1 tvars) type_insts));
   123     val vars1 = map (apsnd instT1) vars;
   124     val vars1 = map (apsnd instT1) vars;
   124 
   125 
   125     (*term instantiations*)
   126     (*term instantiations*)
   126     val (xs, ss) = split_list term_insts;
   127     val (xs, ss) = split_list term_insts;
   127     val Ts = map (the_type vars1) xs;
   128     val Ts = map (the_type vars1) xs;
   128     val ((ts, inferred), ctxt2) = read_terms ss Ts ctxt1;
   129     val ((ts, inferred), ctxt2) = read_terms ss Ts ctxt1;
   129 
   130 
   130     (*implicit type instantiations*)
   131     (*implicit type instantiations*)
   131     val instT2 = Term_Subst.instantiateT inferred;
   132     val instT2 = Term_Subst.instantiateT (Term_Subst.TVars.table inferred);
   132     val vars2 = map (apsnd instT2) vars1;
   133     val vars2 = map (apsnd instT2) vars1;
   133     val inst2 =
   134     val inst2 =
   134       Term_Subst.instantiate ([], map2 (fn (xi, _) => fn t => ((xi, Term.fastype_of t), t)) xs ts)
   135       Term_Subst.instantiate (Term_Subst.TVars.empty,
       
   136         fold2 (fn (xi, _) => fn t => Term_Subst.Vars.add ((xi, Term.fastype_of t), t))
       
   137           xs ts Term_Subst.Vars.empty)
   135       #> Envir.beta_norm;
   138       #> Envir.beta_norm;
   136 
   139 
   137     val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars;
   140     val inst_tvars = map_filter (make_instT (instT2 o instT1)) tvars;
   138     val inst_vars = map_filter (make_inst inst2) vars2;
   141     val inst_vars = map_filter (make_inst inst2) vars2;
   139   in ((inst_tvars, inst_vars), ctxt2) end;
   142   in ((inst_tvars, inst_vars), ctxt2) end;