src/Pure/cterm_items.ML
author wenzelm
Mon, 27 Oct 2025 15:16:32 +0100
changeset 83417 b51e4a526897
parent 82855 df2d774bcf21
permissions -rw-r--r--
clarified signature;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/cterm_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: for type thm and cterm.
79162
c1bbaa0d89b4 tuned comments;
wenzelm
parents: 79121
diff changeset
     5
See also Pure/term_items.ML.
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     6
*)
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     7
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     8
structure Ctermtab:
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
     9
sig
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    10
  include TABLE
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    11
  val cterm_cache: (cterm -> 'a) -> cterm -> 'a
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    12
end =
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    13
struct
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    14
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    15
structure Table = Table(type key = cterm val ord = Thm.fast_term_ord);
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    16
open Table;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    17
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    18
fun cterm_cache f = Cache.create empty lookup update f;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    19
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    20
end;
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    21
77903
38d0a90e87c1 more operations;
wenzelm
parents: 74272
diff changeset
    22
structure Ctermset = Set(Ctermtab.Key);
38d0a90e87c1 more operations;
wenzelm
parents: 74272
diff changeset
    23
74270
ad2899cdd528 clarified modules;
wenzelm
parents:
diff changeset
    24
74271
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    25
structure Cterms:
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    26
sig
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    27
  include TERM_ITEMS
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    28
  val add_vars: thm -> set -> set
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    29
  val add_frees: thm -> set -> set
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    30
end =
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    31
struct
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    32
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    33
structure Term_Items = Term_Items
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    34
(
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    35
  type key = cterm;
79121
6a84d18fa548 more operations;
wenzelm
parents: 77903
diff changeset
    36
  val ord = Thm.fast_term_ord;
74271
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    37
);
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    38
open Term_Items;
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    39
81959
fae61f1c8113 minor performance tuning: more fine-grained guard to skip irrelevant items;
wenzelm
parents: 79162
diff changeset
    40
val add_vars = Thm.fold_atomic_cterms {hyps = false} (K Term.is_Var) add_set;
fae61f1c8113 minor performance tuning: more fine-grained guard to skip irrelevant items;
wenzelm
parents: 79162
diff changeset
    41
val add_frees = Thm.fold_atomic_cterms {hyps = true} (K Term.is_Free) add_set;
74271
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    42
64be5f224462 clarified signature;
wenzelm
parents: 74270
diff changeset
    43
end;
74272
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    44
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    45
82855
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    46
structure Proptab = Table
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    47
(
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    48
  type key = thm
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    49
  val ord = pointer_eq_ord (Term_Ord.fast_term_ord o apply2 Thm.full_prop_of)
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    50
);
df2d774bcf21 proper thm ord that conforms to Thm.eq_thm_prop (amending f5fd9b41188a): relevant for declarations in a locale contex with assumptions, e.g. "locale test = assumes True begin declare refl [rule del] end";
wenzelm
parents: 81959
diff changeset
    51
74272
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    52
structure Thmtab:
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    53
sig
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    54
  include TABLE
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    55
  val thm_cache: (thm -> 'a) -> thm -> 'a
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    56
end =
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    57
struct
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    58
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    59
structure Table = Table(type key = thm val ord = Thm.thm_ord);
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    60
open Table;
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    61
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    62
fun thm_cache f = Cache.create empty lookup update f;
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    63
0f3ca0cd8071 clarified signature;
wenzelm
parents: 74271
diff changeset
    64
end;
77903
38d0a90e87c1 more operations;
wenzelm
parents: 74272
diff changeset
    65
38d0a90e87c1 more operations;
wenzelm
parents: 74272
diff changeset
    66
structure Thmset = Set(Thmtab.Key);