src/Pure/Tools/named_thms.ML
author wenzelm
Thu Mar 20 16:04:34 2008 +0100 (2008-03-20)
changeset 26363 9d95309f8069
parent 24867 e5b55d7be9bb
child 26397 df68e8dfd0e3
permissions -rw-r--r--
export add/del_thm;
wenzelm@24047
     1
(*  Title:      Pure/Tools/named_thms.ML
wenzelm@24047
     2
    ID:         $Id$
wenzelm@24047
     3
    Author:     Makarius
wenzelm@24047
     4
wenzelm@24047
     5
Named collections of theorems in canonical order.
wenzelm@24047
     6
*)
wenzelm@24047
     7
wenzelm@24047
     8
signature NAMED_THMS =
wenzelm@24047
     9
sig
wenzelm@24047
    10
  val get: Proof.context -> thm list
wenzelm@24047
    11
  val pretty: Proof.context -> Pretty.T
wenzelm@26363
    12
  val add_thm: thm -> Context.generic -> Context.generic
wenzelm@26363
    13
  val del_thm: thm -> Context.generic -> Context.generic
wenzelm@24047
    14
  val add: attribute
wenzelm@24047
    15
  val del: attribute
wenzelm@24047
    16
  val setup: theory -> theory
wenzelm@24047
    17
end;
wenzelm@24047
    18
wenzelm@24047
    19
functor NamedThmsFun(val name: string val description: string): NAMED_THMS =
wenzelm@24047
    20
struct
wenzelm@24047
    21
wenzelm@24047
    22
structure Data = GenericDataFun
wenzelm@24047
    23
(
wenzelm@24047
    24
  type T = thm list;
wenzelm@24047
    25
  val empty = [];
wenzelm@24047
    26
  val extend = I;
wenzelm@24047
    27
  fun merge _ = Thm.merge_thms;
wenzelm@24047
    28
);
wenzelm@24047
    29
wenzelm@24047
    30
val get = Data.get o Context.Proof;
wenzelm@24047
    31
wenzelm@24047
    32
fun pretty ctxt =
wenzelm@24047
    33
  Pretty.big_list (description ^ ":") (map (ProofContext.pretty_thm ctxt) (get ctxt));
wenzelm@24047
    34
wenzelm@26363
    35
val add_thm = Data.map o Thm.add_thm;
wenzelm@26363
    36
val del_thm = Data.map o Thm.del_thm;
wenzelm@26363
    37
wenzelm@26363
    38
val add = Thm.declaration_attribute add_thm;
wenzelm@26363
    39
val del = Thm.declaration_attribute del_thm;
wenzelm@24047
    40
wenzelm@24047
    41
val setup =
wenzelm@24047
    42
  Attrib.add_attributes [(name, Attrib.add_del_args add del, "declaration of " ^ description)];
wenzelm@24047
    43
wenzelm@24867
    44
val _ =
wenzelm@24867
    45
  OuterSyntax.improper_command ("print_" ^ name ^ "_rules") ("print " ^ description)
wenzelm@24117
    46
    OuterKeyword.diag
wenzelm@24117
    47
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
wenzelm@24867
    48
      Toplevel.keep (Pretty.writeln o pretty o Toplevel.context_of)));
wenzelm@24117
    49
wenzelm@24047
    50
end;