src/Pure/Tools/named_thms.ML
author wenzelm
Sun, 29 Jul 2007 14:30:03 +0200
changeset 24047 47b588ce11ec
child 24117 94210ad252e3
permissions -rw-r--r--
Named collections of theorems in canonical order.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Tools/named_thms.ML
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     3
    Author:     Makarius
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     4
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     5
Named collections of theorems in canonical order.
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     6
*)
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     7
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     8
signature NAMED_THMS =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     9
sig
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    10
  val get: Proof.context -> thm list
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    11
  val pretty: Proof.context -> Pretty.T
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    12
  val print: Proof.context -> unit
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    13
  val add: attribute
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    14
  val del: attribute
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    15
  val setup: theory -> theory
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    16
end;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    17
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    18
functor NamedThmsFun(val name: string val description: string): NAMED_THMS =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    19
struct
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    20
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    21
structure Data = GenericDataFun
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    22
(
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    23
  type T = thm list;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    24
  val empty = [];
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    25
  val extend = I;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    26
  fun merge _ = Thm.merge_thms;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    27
);
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    28
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    29
val get = Data.get o Context.Proof;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    30
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    31
fun pretty ctxt =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    32
  Pretty.big_list (description ^ ":") (map (ProofContext.pretty_thm ctxt) (get ctxt));
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    33
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    34
val print = Pretty.writeln o pretty;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    35
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    36
val add = Thm.declaration_attribute (Data.map o Thm.add_thm);
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    37
val del = Thm.declaration_attribute (Data.map o Thm.del_thm);
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    38
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    39
val setup =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    40
  Attrib.add_attributes [(name, Attrib.add_del_args add del, "declaration of " ^ description)];
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    41
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    42
end;