src/Pure/Tools/rule_insts.ML
changeset 55156 3ca79ee6eb33
parent 55151 f331472f1027
child 58027 dc58ab4d9f44
equal deleted inserted replaced
55155:a1affe3eb3fd 55156:3ca79ee6eb33
    70       | TVar ((a, _), _) => insert (op =) a
    70       | TVar ((a, _), _) => insert (op =) a
    71       | _ => I);
    71       | _ => I);
    72 
    72 
    73 in
    73 in
    74 
    74 
    75 fun read_termTs ctxt schematic ss Ts =
    75 fun read_termTs ctxt ss Ts =
    76   let
    76   let
    77     fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt;
    77     fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt;
    78     val ts = map2 parse Ts ss;
    78     val ts = map2 parse Ts ss;
    79     val ts' =
    79     val ts' =
    80       map2 (Type.constraint o Type_Infer.paramify_vars) Ts ts
    80       map2 (Type.constraint o Type_Infer.paramify_vars) Ts ts
    81       |> Syntax.check_terms ((schematic ? Proof_Context.set_mode Proof_Context.mode_schematic) ctxt)
    81       |> Syntax.check_terms ctxt
    82       |> Variable.polymorphic ctxt;
    82       |> Variable.polymorphic ctxt;
    83     val Ts' = map Term.fastype_of ts';
    83     val Ts' = map Term.fastype_of ts';
    84     val tyenv = fold Type.raw_match (Ts ~~ Ts') Vartab.empty;
    84     val tyenv = fold Type.raw_match (Ts ~~ Ts') Vartab.empty;
    85   in (ts', map (apsnd snd) (Vartab.dest tyenv)) end;
    85   in (ts', map (apsnd snd) (Vartab.dest tyenv)) end;
    86 
    86 
   110 
   110 
   111     (* term instantiations *)
   111     (* term instantiations *)
   112 
   112 
   113     val (xs, ss) = split_list term_insts;
   113     val (xs, ss) = split_list term_insts;
   114     val Ts = map (the_type vars1) xs;
   114     val Ts = map (the_type vars1) xs;
   115     val (ts, inferred) = read_termTs ctxt false ss Ts;
   115     val (ts, inferred) = read_termTs ctxt ss Ts;
   116 
   116 
   117     val instT2 = Term.typ_subst_TVars inferred;
   117     val instT2 = Term.typ_subst_TVars inferred;
   118     val vars2 = map (apsnd instT2) vars1;
   118     val vars2 = map (apsnd instT2) vars1;
   119     val inst2 = instantiate (xs ~~ ts);
   119     val inst2 = instantiate (xs ~~ ts);
   120 
   120 
   249                SOME T => typ_subst_atomic Tinsts_env T
   249                SOME T => typ_subst_atomic Tinsts_env T
   250              | NONE => absent xi);
   250              | NONE => absent xi);
   251         val (xis, ss) = Library.split_list tinsts;
   251         val (xis, ss) = Library.split_list tinsts;
   252         val Ts = map get_typ xis;
   252         val Ts = map get_typ xis;
   253 
   253 
   254         val (ts, envT) = read_termTs ctxt' true ss Ts;
   254         val (ts, envT) =
       
   255           read_termTs (Proof_Context.set_mode Proof_Context.mode_schematic ctxt') ss Ts;
   255         val envT' = map (fn (ixn, T) =>
   256         val envT' = map (fn (ixn, T) =>
   256           (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env;
   257           (TVar (ixn, the (rsorts ixn)), T)) envT @ Tinsts_env;
   257         val cenv =
   258         val cenv =
   258           map
   259           map
   259             (fn (xi, t) =>
   260             (fn (xi, t) =>