src/Pure/term_subst.ML
author wenzelm
Thu, 30 Nov 2006 14:17:32 +0100
changeset 21607 3698319f6503
parent 21315 be2669fe8363
child 29269 5c25a2012975
permissions -rw-r--r--
zero_var_indexes_inst: multiple terms; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/term_subst.ML
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     3
    Author:     Makarius
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     4
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     5
Efficient term substitution -- avoids copying.
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     6
*)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     7
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     8
signature TERM_SUBST =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
     9
sig
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    10
  val generalize: string list * string list -> int -> term -> term
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    11
  val generalizeT: string list -> int -> typ -> typ
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    12
  val generalize_option: string list * string list -> int -> term -> term option
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    13
  val generalizeT_option: string list -> int -> typ -> typ option
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    14
  val instantiateT_maxidx: ((indexname * sort) * (typ * int)) list -> typ -> int -> typ * int
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    15
  val instantiate_maxidx:
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    16
    ((indexname * sort) * (typ * int)) list * ((indexname * typ) * (term * int)) list ->
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    17
    term -> int -> term * int
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    18
  val instantiate: ((indexname * sort) * typ) list * ((indexname * typ) * term) list ->
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    19
    term -> term
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    20
  val instantiateT: ((indexname * sort) * typ) list -> typ -> typ
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    21
  val instantiate_option: ((indexname * sort) * typ) list * ((indexname * typ) * term) list ->
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    22
    term -> term option
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    23
  val instantiateT_option: ((indexname * sort) * typ) list -> typ -> typ option
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    24
  val zero_var_indexes: term -> term
21607
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
    25
  val zero_var_indexes_inst: term list ->
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    26
    ((indexname * sort) * typ) list * ((indexname * typ) * term) list
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    27
end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    28
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    29
structure TermSubst: TERM_SUBST =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    30
struct
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    31
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    32
(* generalization of fixed variables *)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    33
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    34
local
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    35
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    36
exception SAME;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    37
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    38
fun generalizeT_same [] _ _ = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    39
  | generalizeT_same tfrees idx ty =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    40
      let
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    41
        fun gen_typ (Type (a, Ts)) = Type (a, gen_typs Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    42
          | gen_typ (TFree (a, S)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    43
              if member (op =) tfrees a then TVar ((a, idx), S)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    44
              else raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    45
          | gen_typ _ = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    46
        and gen_typs (T :: Ts) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    47
            (gen_typ T :: (gen_typs Ts handle SAME => Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    48
              handle SAME => T :: gen_typs Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    49
          | gen_typs [] = raise SAME;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    50
      in gen_typ ty end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    51
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    52
fun generalize_same ([], []) _ _ = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    53
  | generalize_same (tfrees, frees) idx tm =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    54
      let
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    55
        val genT = generalizeT_same tfrees idx;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    56
        fun gen (Free (x, T)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    57
              if member (op =) frees x then
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    58
                Var (Name.clean_index (x, idx), genT T handle SAME => T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    59
              else Free (x, genT T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    60
          | gen (Var (xi, T)) = Var (xi, genT T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    61
          | gen (Const (c, T)) = Const (c, genT T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    62
          | gen (Bound _) = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    63
          | gen (Abs (x, T, t)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    64
              (Abs (x, genT T, gen t handle SAME => t)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    65
                handle SAME => Abs (x, T, gen t))
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    66
          | gen (t $ u) = (gen t $ (gen u handle SAME => u) handle SAME => t $ gen u);
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    67
      in gen tm end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    68
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    69
in
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    70
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    71
fun generalize names i tm = generalize_same names i tm handle SAME => tm;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    72
fun generalizeT names i ty = generalizeT_same names i ty handle SAME => ty;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    73
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    74
fun generalize_option names i tm = SOME (generalize_same names i tm) handle SAME => NONE;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    75
fun generalizeT_option names i ty = SOME (generalizeT_same names i ty) handle SAME => NONE;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    76
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    77
end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    78
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    79
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    80
(* instantiation of schematic variables (types before terms) -- recomputes maxidx *)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    81
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    82
local
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    83
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    84
fun no_index (x, y) = (x, (y, ~1));
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    85
fun no_indexes1 inst = map no_index inst;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    86
fun no_indexes2 (inst1, inst2) = (map no_index inst1, map no_index inst2);
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    87
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    88
exception SAME;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    89
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
    90
fun instantiateT_same maxidx instT ty =
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    91
  let
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
    92
    fun maxify i = if i > ! maxidx then maxidx := i else ();
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
    93
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    94
    fun subst_typ (Type (a, Ts)) = Type (a, subst_typs Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    95
      | subst_typ (TVar ((a, i), S)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    96
          (case AList.lookup Term.eq_tvar instT ((a, i), S) of
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    97
            SOME (T, j) => (maxify j; T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    98
          | NONE => (maxify i; raise SAME))
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
    99
      | subst_typ _ = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   100
    and subst_typs (T :: Ts) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   101
        (subst_typ T :: (subst_typs Ts handle SAME => Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   102
          handle SAME => T :: subst_typs Ts)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   103
      | subst_typs [] = raise SAME;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   104
  in subst_typ ty end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   105
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   106
fun instantiate_same maxidx (instT, inst) tm =
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   107
  let
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   108
    fun maxify i = if i > ! maxidx then maxidx := i else ();
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   109
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   110
    val substT = instantiateT_same maxidx instT;
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   111
    fun subst (Const (c, T)) = Const (c, substT T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   112
      | subst (Free (x, T)) = Free (x, substT T)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   113
      | subst (Var ((x, i), T)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   114
          let val (T', same) = (substT T, false) handle SAME => (T, true) in
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   115
            (case AList.lookup Term.eq_var inst ((x, i), T') of
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   116
               SOME (t, j) => (maxify j; t)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   117
             | NONE => (maxify i; if same then raise SAME else Var ((x, i), T')))
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   118
          end
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   119
      | subst (Bound _) = raise SAME
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   120
      | subst (Abs (x, T, t)) =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   121
          (Abs (x, substT T, subst t handle SAME => t)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   122
            handle SAME => Abs (x, T, subst t))
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   123
      | subst (t $ u) = (subst t $ (subst u handle SAME => u) handle SAME => t $ subst u);
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   124
  in subst tm end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   125
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   126
in
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   127
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   128
fun instantiateT_maxidx instT ty i =
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   129
  let val maxidx = ref i
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   130
  in (instantiateT_same maxidx instT ty handle SAME => ty, ! maxidx) end;
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   131
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   132
fun instantiate_maxidx insts tm i =
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   133
  let val maxidx = ref i
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   134
  in (instantiate_same maxidx insts tm handle SAME => tm, ! maxidx) end;
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   135
21315
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   136
fun instantiateT [] ty = ty
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   137
  | instantiateT instT ty =
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   138
      (instantiateT_same (ref ~1) (no_indexes1 instT) ty handle SAME => ty);
21184
35baf14cfb6d instantiate: avoid global references;
wenzelm
parents: 20513
diff changeset
   139
21315
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   140
fun instantiate ([], []) tm = tm
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   141
  | instantiate insts tm =
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   142
      (instantiate_same (ref ~1) (no_indexes2 insts) tm handle SAME => tm);
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   143
21315
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   144
fun instantiateT_option [] _ = NONE
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   145
  | instantiateT_option instT ty =
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   146
      (SOME (instantiateT_same (ref ~1) (no_indexes1 instT) ty) handle SAME => NONE);
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   147
21315
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   148
fun instantiate_option ([], []) _ = NONE
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   149
  | instantiate_option insts tm =
be2669fe8363 instantiate: tuned indentity case;
wenzelm
parents: 21184
diff changeset
   150
      (SOME (instantiate_same (ref ~1) (no_indexes2 insts) tm) handle SAME => NONE);
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   151
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   152
end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   153
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   154
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   155
(* zero var indexes *)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   156
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   157
fun zero_var_inst vars =
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   158
  fold (fn v as ((x, i), X) => fn (inst, used) =>
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   159
    let
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   160
      val ([x'], used') = Name.variants [if Name.is_bound x then "u" else x] used;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   161
    in if x = x' andalso i = 0 then (inst, used') else ((v, ((x', 0), X)) :: inst, used') end)
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   162
  vars ([], Name.context) |> #1;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   163
21607
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   164
fun zero_var_indexes_inst ts =
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   165
  let
21607
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   166
    val tvars = sort Term.tvar_ord (fold Term.add_tvars ts []);
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   167
    val instT = map (apsnd TVar) (zero_var_inst tvars);
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   168
    val vars = sort Term.var_ord (map (apsnd (instantiateT instT)) (fold Term.add_vars ts []));
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   169
    val inst = map (apsnd Var) (zero_var_inst vars);
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   170
  in (instT, inst) end;
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   171
21607
3698319f6503 zero_var_indexes_inst: multiple terms;
wenzelm
parents: 21315
diff changeset
   172
fun zero_var_indexes t = instantiate (zero_var_indexes_inst [t]) t;
20513
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   173
4294eb252283 Efficient term substitution -- avoids copying.
wenzelm
parents:
diff changeset
   174
end;