src/Pure/term_items.ML
author wenzelm
Wed, 20 Dec 2023 14:26:18 +0100
changeset 79320 bbac3e8a5070
parent 79317 788921b906e1
child 79380 b9d80d5aca8e
permissions -rw-r--r--
more permissive: allow collapse of term variables for equal results, e.g. relevant for metis (line 1882 of "~~/src/HOL/List.thy");
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/term_items.ML
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     3
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     4
Scalable collections of term items:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     5
  - table: e.g. for instantiation
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     6
  - set with order of addition, e.g. occurrences within term
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     7
*)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     8
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     9
signature TERM_ITEMS =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    10
sig
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    11
  structure Key: KEY
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    12
  type key
79317
788921b906e1 clarified signature;
wenzelm
parents: 79199
diff changeset
    13
  exception DUP of key
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    14
  type 'a table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    15
  val empty: 'a table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    16
  val build: ('a table -> 'a table) -> 'a table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    17
  val size: 'a table -> int
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    18
  val is_empty: 'a table -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    19
  val map: (key -> 'a -> 'b) -> 'a table -> 'b table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    20
  val fold: (key * 'b -> 'a -> 'a) -> 'b table -> 'a -> 'a
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    21
  val fold_rev: (key * 'b -> 'a -> 'a) -> 'b table -> 'a -> 'a
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    22
  val dest: 'a table -> (key * 'a) list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    23
  val keys: 'a table -> key list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    24
  val exists: (key * 'a -> bool) -> 'a table -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    25
  val forall: (key * 'a -> bool) -> 'a table -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    26
  val get_first: (key * 'a -> 'b option) -> 'a table -> 'b option
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    27
  val lookup: 'a table -> key -> 'a option
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    28
  val defined: 'a table -> key -> bool
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    29
  val update: key * 'a -> 'a table -> 'a table
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    30
  val remove: key -> 'a table -> 'a table
79320
bbac3e8a5070 more permissive: allow collapse of term variables for equal results, e.g. relevant for metis (line 1882 of "~~/src/HOL/List.thy");
wenzelm
parents: 79317
diff changeset
    31
  val insert: ('a * 'a -> bool) -> key * 'a -> 'a table -> 'a table    (*exception DUP*)
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    32
  val add: key * 'a -> 'a table -> 'a table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    33
  val make: (key * 'a) list -> 'a table
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    34
  val make1: key * 'a -> 'a table
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    35
  val make2: key * 'a -> key * 'a -> 'a table
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    36
  val make3: key * 'a -> key * 'a -> key * 'a -> 'a table
79199
8b77c95ed36a more operations;
wenzelm
parents: 79146
diff changeset
    37
  val unsynchronized_cache: (key -> 'a) -> key -> 'a
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    38
  type set = int table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    39
  val add_set: key -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    40
  val make_set: key list -> set
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    41
  val make1_set: key -> set
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    42
  val make2_set: key -> key -> set
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    43
  val make3_set: key -> key -> key -> set
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    44
  val list_set: set -> key list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    45
  val list_set_rev: set -> key list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    46
  val subset: set * set -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    47
  val eq_set: set * set -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    48
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    49
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    50
functor Term_Items(Key: KEY): TERM_ITEMS =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    51
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    52
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    53
(* keys *)
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    54
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    55
structure Key = Key;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    56
type key = Key.key;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    57
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    58
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    59
(* table with length *)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    60
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    61
structure Table = Table(Key);
79317
788921b906e1 clarified signature;
wenzelm
parents: 79199
diff changeset
    62
exception DUP = Table.DUP;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    63
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    64
datatype 'a table = Table of 'a Table.table;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    65
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    66
val empty = Table Table.empty;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    67
fun build (f: 'a table -> 'a table) = f empty;
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    68
fun is_empty (Table tab) = Table.is_empty tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    69
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    70
fun size (Table tab) = Table.size tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    71
fun dest (Table tab) = Table.dest tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    72
fun keys (Table tab) = Table.keys tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    73
fun exists pred (Table tab) = Table.exists pred tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    74
fun forall pred (Table tab) = Table.forall pred tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    75
fun get_first get (Table tab) = Table.get_first get tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    76
fun lookup (Table tab) = Table.lookup tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    77
fun defined (Table tab) = Table.defined tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    78
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    79
fun update e (Table tab) = Table (Table.update e tab);
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    80
fun remove x (Table tab) = Table (Table.delete_safe x tab);
79320
bbac3e8a5070 more permissive: allow collapse of term variables for equal results, e.g. relevant for metis (line 1882 of "~~/src/HOL/List.thy");
wenzelm
parents: 79317
diff changeset
    81
fun insert eq e (Table tab) = Table (Table.insert eq e tab);
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    82
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    83
fun add entry (Table tab) = Table (Table.default entry tab);
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    84
fun make es = build (fold add es);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    85
fun make1 e = build (add e);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    86
fun make2 e1 e2 = build (add e1 #> add e2);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    87
fun make3 e1 e2 e3 = build (add e1 #> add e2 #> add e3);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    88
79199
8b77c95ed36a more operations;
wenzelm
parents: 79146
diff changeset
    89
val unsynchronized_cache = Table.unsynchronized_cache;
8b77c95ed36a more operations;
wenzelm
parents: 79146
diff changeset
    90
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    91
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    92
(* set with order of addition *)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    93
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    94
type set = int table;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    95
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    96
fun add_set x (Table tab) =
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    97
  Table (if Table.defined tab x then tab else Table.update_new (x, Table.size tab + 1) tab);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    98
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    99
fun make_set xs = build (fold add_set xs);
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   100
fun make1_set e = build (add_set e);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   101
fun make2_set e1 e2 = build (add_set e1 #> add_set e2);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   102
fun make3_set e1 e2 e3 = build (add_set e1 #> add_set e2 #> add_set e3);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   103
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   104
fun subset (A: set, B: set) = forall (defined B o #1) A;
77835
c18c0dbefd55 performance tuning: proper pointer_eq;
wenzelm
parents: 77828
diff changeset
   105
fun eq_set (A: set, B: set) = pointer_eq (A, B) orelse size A = size B andalso subset (A, B);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   106
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   107
fun list_set_ord ord (Table tab) = tab |> Table.dest |> sort (ord o apply2 #2) |> map #1;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   108
val list_set = list_set_ord int_ord;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   109
val list_set_rev = list_set_ord (rev_order o int_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   110
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   111
fun map f (Table tab) = Table (Table.map f tab);
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   112
fun fold f (Table tab) = Table.fold f tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   113
fun fold_rev f (Table tab) = Table.fold_rev f tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   114
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   115
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   116
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   117
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   118
structure TFrees:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   119
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   120
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   121
  val add_tfreesT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   122
  val add_tfrees: term -> set -> set
74278
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   123
  val add_tfreesT_unless: (string * sort -> bool) -> typ -> set -> set
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   124
  val add_tfrees_unless: (string * sort -> bool) -> term -> set -> set
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   125
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   126
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   127
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   128
structure Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   129
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   130
  type key = string * sort;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   131
  val ord = pointer_eq_ord (prod_ord fast_string_ord Term_Ord.sort_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   132
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   133
open Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   134
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   135
val add_tfreesT = fold_atyps (fn TFree v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   136
val add_tfrees = fold_types add_tfreesT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   137
74278
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   138
fun add_tfreesT_unless pred = Term.fold_atyps (fn TFree v => not (pred v) ? add_set v | _ => I);
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   139
fun add_tfrees_unless pred = fold_types (add_tfreesT_unless pred);
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   140
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   141
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   142
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   143
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   144
structure TVars:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   145
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   146
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   147
  val add_tvarsT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   148
  val add_tvars: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   149
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   150
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   151
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   152
structure Term_Items = Term_Items(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   153
  type key = indexname * sort;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   154
  val ord = pointer_eq_ord (prod_ord Term_Ord.fast_indexname_ord Term_Ord.sort_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   155
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   156
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   157
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   158
val add_tvarsT = fold_atyps (fn TVar v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   159
val add_tvars = fold_types add_tvarsT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   160
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   161
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   162
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   163
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   164
structure Frees:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   165
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   166
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   167
  val add_frees: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   168
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   169
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   170
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   171
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   172
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   173
  type key = string * typ;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   174
  val ord = pointer_eq_ord (prod_ord fast_string_ord Term_Ord.typ_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   175
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   176
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   177
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   178
val add_frees = fold_aterms (fn Free v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   179
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   180
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   181
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   182
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   183
structure Vars:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   184
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   185
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   186
  val add_vars: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   187
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   188
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   189
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   190
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   191
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   192
  type key = indexname * typ;
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
   193
  val ord = pointer_eq_ord (prod_ord Term_Ord.fast_indexname_ord Term_Ord.typ_ord);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   194
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   195
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   196
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   197
val add_vars = fold_aterms (fn Var v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   198
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   199
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   200
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   201
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   202
structure Names:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   203
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   204
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   205
  val add_tfree_namesT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   206
  val add_tfree_names: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   207
  val add_free_names: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   208
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   209
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   210
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   211
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   212
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   213
  type key = string;
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
   214
  val ord = fast_string_ord;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   215
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   216
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   217
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   218
val add_tfree_namesT = fold_atyps (fn TFree (a, _) => add_set a | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   219
val add_tfree_names = fold_types add_tfree_namesT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   220
val add_free_names = fold_aterms (fn Free (x, _) => add_set x | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   221
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   222
end;