src/Pure/Tools/named_thms.ML
author wenzelm
Thu, 22 Nov 2007 14:51:34 +0100
changeset 25456 6f79698f294d
parent 24867 e5b55d7be9bb
child 26363 9d95309f8069
permissions -rw-r--r--
tuned;
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 add: attribute
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    13
  val del: attribute
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    14
  val setup: theory -> theory
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    15
end;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    16
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    17
functor NamedThmsFun(val name: string val description: string): NAMED_THMS =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    18
struct
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    19
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    20
structure Data = GenericDataFun
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    21
(
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    22
  type T = thm list;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    23
  val empty = [];
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    24
  val extend = I;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    25
  fun merge _ = Thm.merge_thms;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    26
);
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
val get = Data.get o Context.Proof;
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    29
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    30
fun pretty ctxt =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    31
  Pretty.big_list (description ^ ":") (map (ProofContext.pretty_thm ctxt) (get ctxt));
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    32
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    33
val add = Thm.declaration_attribute (Data.map o Thm.add_thm);
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    34
val del = Thm.declaration_attribute (Data.map o Thm.del_thm);
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 setup =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    37
  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
    38
24867
e5b55d7be9bb simplified interfaces for outer syntax;
wenzelm
parents: 24117
diff changeset
    39
val _ =
e5b55d7be9bb simplified interfaces for outer syntax;
wenzelm
parents: 24117
diff changeset
    40
  OuterSyntax.improper_command ("print_" ^ name ^ "_rules") ("print " ^ description)
24117
94210ad252e3 added toplevel print command;
wenzelm
parents: 24047
diff changeset
    41
    OuterKeyword.diag
94210ad252e3 added toplevel print command;
wenzelm
parents: 24047
diff changeset
    42
    (Scan.succeed (Toplevel.no_timing o Toplevel.unknown_context o
24867
e5b55d7be9bb simplified interfaces for outer syntax;
wenzelm
parents: 24117
diff changeset
    43
      Toplevel.keep (Pretty.writeln o pretty o Toplevel.context_of)));
24117
94210ad252e3 added toplevel print command;
wenzelm
parents: 24047
diff changeset
    44
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    45
end;