| author | wenzelm |
| Mon, 27 Oct 2025 15:16:32 +0100 | |
| changeset 83417 | b51e4a526897 |
| parent 82855 | df2d774bcf21 |
| permissions | -rw-r--r-- |
| 74270 | 1 |
(* Title: Pure/cterm_items.ML |
2 |
Author: Makarius |
|
3 |
||
4 |
Scalable collections of term items: for type thm and cterm. |
|
| 79162 | 5 |
See also Pure/term_items.ML. |
| 74270 | 6 |
*) |
7 |
||
8 |
structure Ctermtab: |
|
9 |
sig |
|
10 |
include TABLE |
|
11 |
val cterm_cache: (cterm -> 'a) -> cterm -> 'a |
|
12 |
end = |
|
13 |
struct |
|
14 |
||
15 |
structure Table = Table(type key = cterm val ord = Thm.fast_term_ord); |
|
16 |
open Table; |
|
17 |
||
18 |
fun cterm_cache f = Cache.create empty lookup update f; |
|
19 |
||
20 |
end; |
|
21 |
||
| 77903 | 22 |
structure Ctermset = Set(Ctermtab.Key); |
23 |
||
| 74270 | 24 |
|
| 74271 | 25 |
structure Cterms: |
26 |
sig |
|
27 |
include TERM_ITEMS |
|
28 |
val add_vars: thm -> set -> set |
|
29 |
val add_frees: thm -> set -> set |
|
30 |
end = |
|
31 |
struct |
|
32 |
||
33 |
structure Term_Items = Term_Items |
|
34 |
( |
|
35 |
type key = cterm; |
|
| 79121 | 36 |
val ord = Thm.fast_term_ord; |
| 74271 | 37 |
); |
38 |
open Term_Items; |
|
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 | 42 |
|
43 |
end; |
|
| 74272 | 44 |
|
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 | 52 |
structure Thmtab: |
53 |
sig |
|
54 |
include TABLE |
|
55 |
val thm_cache: (thm -> 'a) -> thm -> 'a |
|
56 |
end = |
|
57 |
struct |
|
58 |
||
59 |
structure Table = Table(type key = thm val ord = Thm.thm_ord); |
|
60 |
open Table; |
|
61 |
||
62 |
fun thm_cache f = Cache.create empty lookup update f; |
|
63 |
||
64 |
end; |
|
| 77903 | 65 |
|
66 |
structure Thmset = Set(Thmtab.Key); |