src/Pure/Tools/named_thms.ML
author wenzelm
Sun Mar 15 15:59:44 2009 +0100 (2009-03-15)
changeset 30528 7173bf123335
parent 29579 cb520b766e00
child 31901 e280491f36b8
permissions -rw-r--r--
simplified attribute setup;
wenzelm@24047
     1
(*  Title:      Pure/Tools/named_thms.ML
wenzelm@24047
     2
    Author:     Makarius
wenzelm@24047
     3
wenzelm@24047
     4
Named collections of theorems in canonical order.
wenzelm@24047
     5
*)
wenzelm@24047
     6
wenzelm@24047
     7
signature NAMED_THMS =
wenzelm@24047
     8
sig
wenzelm@24047
     9
  val get: Proof.context -> thm list
wenzelm@26363
    10
  val add_thm: thm -> Context.generic -> Context.generic
wenzelm@26363
    11
  val del_thm: thm -> Context.generic -> Context.generic
wenzelm@24047
    12
  val add: attribute
wenzelm@24047
    13
  val del: attribute
wenzelm@24047
    14
  val setup: theory -> theory
wenzelm@24047
    15
end;
wenzelm@24047
    16
wenzelm@24047
    17
functor NamedThmsFun(val name: string val description: string): NAMED_THMS =
wenzelm@24047
    18
struct
wenzelm@24047
    19
wenzelm@24047
    20
structure Data = GenericDataFun
wenzelm@24047
    21
(
wenzelm@24047
    22
  type T = thm list;
wenzelm@24047
    23
  val empty = [];
wenzelm@24047
    24
  val extend = I;
wenzelm@24047
    25
  fun merge _ = Thm.merge_thms;
wenzelm@24047
    26
);
wenzelm@24047
    27
wenzelm@24047
    28
val get = Data.get o Context.Proof;
wenzelm@24047
    29
wenzelm@26363
    30
val add_thm = Data.map o Thm.add_thm;
wenzelm@26363
    31
val del_thm = Data.map o Thm.del_thm;
wenzelm@26363
    32
wenzelm@26363
    33
val add = Thm.declaration_attribute add_thm;
wenzelm@26363
    34
val del = Thm.declaration_attribute del_thm;
wenzelm@24047
    35
wenzelm@24047
    36
val setup =
wenzelm@30528
    37
  Attrib.setup (Binding.name name) (Attrib.add_del add del) ("declaration of " ^ description) #>
haftmann@29579
    38
  PureThy.add_thms_dynamic (Binding.name name, Data.get);
wenzelm@24047
    39
wenzelm@24047
    40
end;