src/Pure/Tools/named_thms.ML
author wenzelm
Sun Nov 08 16:30:41 2009 +0100 (2009-11-08)
changeset 33519 e31a85f92ce9
parent 33453 fe551dc9d4bd
child 36296 5cc547abd995
permissions -rw-r--r--
adapted Generic_Data, Proof_Data;
tuned;
wenzelm@24047
     1
(*  Title:      Pure/Tools/named_thms.ML
wenzelm@24047
     2
    Author:     Makarius
wenzelm@24047
     3
wenzelm@33453
     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@31901
    17
functor Named_Thms(val name: string val description: string): NAMED_THMS =
wenzelm@24047
    18
struct
wenzelm@24047
    19
wenzelm@33519
    20
structure Data = Generic_Data
wenzelm@24047
    21
(
wenzelm@33453
    22
  type T = thm Item_Net.T;
wenzelm@33453
    23
  val empty = Thm.full_rules;
wenzelm@24047
    24
  val extend = I;
wenzelm@33519
    25
  val merge = Item_Net.merge;
wenzelm@24047
    26
);
wenzelm@24047
    27
wenzelm@33453
    28
val content = Item_Net.content o Data.get;
wenzelm@33453
    29
val get = content o Context.Proof;
wenzelm@24047
    30
wenzelm@33453
    31
val add_thm = Data.map o Item_Net.update;
wenzelm@33453
    32
val del_thm = Data.map o Item_Net.remove;
wenzelm@26363
    33
wenzelm@26363
    34
val add = Thm.declaration_attribute add_thm;
wenzelm@26363
    35
val del = Thm.declaration_attribute del_thm;
wenzelm@24047
    36
wenzelm@24047
    37
val setup =
wenzelm@30528
    38
  Attrib.setup (Binding.name name) (Attrib.add_del add del) ("declaration of " ^ description) #>
wenzelm@33453
    39
  PureThy.add_thms_dynamic (Binding.name name, content);
wenzelm@24047
    40
wenzelm@24047
    41
end;