src/Pure/term_items.ML
author wenzelm
Thu, 05 Sep 2024 17:39:45 +0200
changeset 80809 4a64fc4d1cde
parent 80583 9a40ec7a2027
child 81259 1c2be1fca2bd
permissions -rw-r--r--
clarified signature: type ML_Pretty.pretty coincides with PolyML.pretty;
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
80583
9a40ec7a2027 more operations;
wenzelm
parents: 80579
diff changeset
    37
  type 'a cache_ops = {apply: key -> 'a, reset: unit -> unit, size: unit -> int};
80579
69cf3c308d6c clarified signature: more operations;
wenzelm
parents: 79413
diff changeset
    38
  val unsynchronized_cache: (key -> 'a) -> 'a cache_ops
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    39
  type set = int table
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    40
  val add_set: key -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    41
  val make_set: key list -> set
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    42
  val make1_set: key -> set
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    43
  val make2_set: key -> key -> set
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    44
  val make3_set: key -> key -> key -> set
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    45
  val list_set: set -> key list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    46
  val list_set_rev: set -> key list
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    47
  val subset: set * set -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    48
  val eq_set: set * set -> bool
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    49
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    50
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    51
functor Term_Items(Key: KEY): TERM_ITEMS =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    52
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    53
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    54
(* keys *)
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    55
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    56
structure Key = Key;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    57
type key = Key.key;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    58
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    59
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    60
(* table with length *)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    61
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    62
structure Table = Table(Key);
79317
788921b906e1 clarified signature;
wenzelm
parents: 79199
diff changeset
    63
exception DUP = Table.DUP;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    64
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    65
datatype 'a table = Table of 'a Table.table;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    66
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    67
val empty = Table Table.empty;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    68
fun build (f: 'a table -> 'a table) = f empty;
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    69
fun is_empty (Table tab) = Table.is_empty tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    70
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    71
fun size (Table tab) = Table.size tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    72
fun dest (Table tab) = Table.dest tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    73
fun keys (Table tab) = Table.keys tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    74
fun exists pred (Table tab) = Table.exists pred tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    75
fun forall pred (Table tab) = Table.forall pred tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    76
fun get_first get (Table tab) = Table.get_first get tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    77
fun lookup (Table tab) = Table.lookup tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    78
fun defined (Table tab) = Table.defined tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    79
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    80
fun update e (Table tab) = Table (Table.update e tab);
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    81
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
    82
fun insert eq e (Table tab) = Table (Table.insert eq e tab);
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
    83
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    84
fun add entry (Table tab) = Table (Table.default entry tab);
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    85
fun make es = build (fold add es);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    86
fun make1 e = build (add e);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    87
fun make2 e1 e2 = build (add e1 #> add e2);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
    88
fun make3 e1 e2 e3 = build (add e1 #> add e2 #> add e3);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    89
80579
69cf3c308d6c clarified signature: more operations;
wenzelm
parents: 79413
diff changeset
    90
type 'a cache_ops = 'a Table.cache_ops;
79199
8b77c95ed36a more operations;
wenzelm
parents: 79146
diff changeset
    91
val unsynchronized_cache = Table.unsynchronized_cache;
8b77c95ed36a more operations;
wenzelm
parents: 79146
diff changeset
    92
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    93
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    94
(* set with order of addition *)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    95
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    96
type set = int table;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    97
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    98
fun add_set x (Table tab) =
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
    99
  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
   100
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   101
fun make_set xs = build (fold add_set xs);
77878
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   102
fun make1_set e = build (add_set e);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   103
fun make2_set e1 e2 = build (add_set e1 #> add_set e2);
35a1788dd6f9 more operations: avoid intermediate list;
wenzelm
parents: 77835
diff changeset
   104
fun make3_set e1 e2 e3 = build (add_set e1 #> add_set e2 #> add_set e3);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   105
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   106
fun subset (A: set, B: set) = forall (defined B o #1) A;
77835
c18c0dbefd55 performance tuning: proper pointer_eq;
wenzelm
parents: 77828
diff changeset
   107
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
   108
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   109
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
   110
val list_set = list_set_ord int_ord;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   111
val list_set_rev = list_set_ord (rev_order o int_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   112
77828
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   113
fun map f (Table tab) = Table (Table.map f tab);
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   114
fun fold f (Table tab) = Table.fold f tab;
6fae9f5157b5 misc tuning: follow Table() more closely;
wenzelm
parents: 74278
diff changeset
   115
fun fold_rev f (Table tab) = Table.fold_rev f tab;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   116
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   117
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   118
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   119
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   120
structure TFrees:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   121
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   122
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   123
  val add_tfreesT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   124
  val add_tfrees: term -> set -> set
74278
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   125
  val add_tfreesT_unless: (string * sort -> bool) -> typ -> set -> set
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   126
  val add_tfrees_unless: (string * sort -> bool) -> term -> set -> set
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   127
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   128
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   129
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   130
structure Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   131
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   132
  type key = string * sort;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   133
  val ord = pointer_eq_ord (prod_ord fast_string_ord Term_Ord.sort_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   134
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   135
open Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   136
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   137
val add_tfreesT = fold_atyps (fn TFree v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   138
val add_tfrees = fold_types add_tfreesT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   139
74278
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   140
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
   141
fun add_tfrees_unless pred = fold_types (add_tfreesT_unless pred);
a123db647573 clarified signature;
wenzelm
parents: 74270
diff changeset
   142
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   143
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   144
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   145
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   146
structure TVars:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   147
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   148
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   149
  val add_tvarsT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   150
  val add_tvars: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   151
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   152
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   153
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   154
structure Term_Items = Term_Items(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   155
  type key = indexname * sort;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   156
  val ord = pointer_eq_ord (prod_ord Term_Ord.fast_indexname_ord Term_Ord.sort_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   157
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   158
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   159
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   160
val add_tvarsT = fold_atyps (fn TVar v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   161
val add_tvars = fold_types add_tvarsT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   162
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   163
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   164
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   165
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   166
structure Frees:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   167
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   168
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   169
  val add_frees: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   170
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   171
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   172
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   173
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   174
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   175
  type key = string * typ;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   176
  val ord = pointer_eq_ord (prod_ord fast_string_ord Term_Ord.typ_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   177
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   178
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   179
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   180
val add_frees = fold_aterms (fn Free v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   181
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   182
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   183
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   184
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   185
structure Vars:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   186
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   187
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   188
  val add_vars: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   189
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   190
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   191
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   192
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   193
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   194
  type key = indexname * typ;
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
   195
  val ord = pointer_eq_ord (prod_ord Term_Ord.fast_indexname_ord Term_Ord.typ_ord);
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   196
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   197
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   198
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   199
val add_vars = fold_aterms (fn Var v => add_set v | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   200
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   201
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   202
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   203
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   204
structure Names:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   205
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   206
  include TERM_ITEMS
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   207
  val add_tfree_namesT: typ -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   208
  val add_tfree_names: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   209
  val add_free_names: term -> set -> set
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   210
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   211
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   212
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   213
structure Term_Items = Term_Items
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   214
(
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   215
  type key = string;
79121
6a84d18fa548 more operations;
wenzelm
parents: 77878
diff changeset
   216
  val ord = fast_string_ord;
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   217
);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   218
open Term_Items;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   219
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   220
val add_tfree_namesT = fold_atyps (fn TFree (a, _) => add_set a | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   221
val add_tfree_names = fold_types add_tfree_namesT;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   222
val add_free_names = fold_aterms (fn Free (x, _) => add_set x | _ => I);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   223
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
   224
end;
79380
b9d80d5aca8e more operations;
wenzelm
parents: 79320
diff changeset
   225
b9d80d5aca8e more operations;
wenzelm
parents: 79320
diff changeset
   226
79413
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   227
structure Types:
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   228
sig
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   229
  include TERM_ITEMS
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   230
  val add_atyps: term -> set -> set
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   231
end =
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   232
struct
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   233
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   234
structure Term_Items = Term_Items(type key = typ val ord = Term_Ord.typ_ord);
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   235
open Term_Items;
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   236
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   237
val add_atyps = (fold_types o fold_atyps) add_set;
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   238
9495bd0112d7 clarified signature;
wenzelm
parents: 79380
diff changeset
   239
end;