src/Pure/Tools/named_thms.ML
author nipkow
Tue, 20 Sep 2011 05:48:23 +0200
changeset 45015 fdac1e9880eb
parent 39557 fe5722fce758
child 45294 3c5d3d286055
permissions -rw-r--r--
Updated IMP to use new induction method
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
    Author:     Makarius
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     3
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
     4
Named collections of theorems in canonical order.
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     5
*)
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
signature NAMED_THMS =
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
     8
sig
36296
5cc547abd995 Item_Net/Named_Thms: export efficient member operation;
wenzelm
parents: 33519
diff changeset
     9
  val member: Proof.context -> thm -> bool
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    10
  val get: Proof.context -> thm list
26363
9d95309f8069 export add/del_thm;
wenzelm
parents: 24867
diff changeset
    11
  val add_thm: thm -> Context.generic -> Context.generic
9d95309f8069 export add/del_thm;
wenzelm
parents: 24867
diff changeset
    12
  val del_thm: thm -> Context.generic -> Context.generic
24047
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
31901
e280491f36b8 renamed NamedThmsFun to Named_Thms;
wenzelm
parents: 30528
diff changeset
    18
functor Named_Thms(val name: string val description: string): NAMED_THMS =
24047
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
33519
e31a85f92ce9 adapted Generic_Data, Proof_Data;
wenzelm
parents: 33453
diff changeset
    21
structure Data = Generic_Data
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    22
(
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    23
  type T = thm Item_Net.T;
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    24
  val empty = Thm.full_rules;
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    25
  val extend = I;
33519
e31a85f92ce9 adapted Generic_Data, Proof_Data;
wenzelm
parents: 33453
diff changeset
    26
  val merge = Item_Net.merge;
24047
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
36296
5cc547abd995 Item_Net/Named_Thms: export efficient member operation;
wenzelm
parents: 33519
diff changeset
    29
val member = Item_Net.member o Data.get o Context.Proof;
5cc547abd995 Item_Net/Named_Thms: export efficient member operation;
wenzelm
parents: 33519
diff changeset
    30
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    31
val content = Item_Net.content o Data.get;
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    32
val get = content o Context.Proof;
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    33
33453
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    34
val add_thm = Data.map o Item_Net.update;
fe551dc9d4bd scalable version of Named_Thms, using Item_Net;
wenzelm
parents: 33307
diff changeset
    35
val del_thm = Data.map o Item_Net.remove;
26363
9d95309f8069 export add/del_thm;
wenzelm
parents: 24867
diff changeset
    36
9d95309f8069 export add/del_thm;
wenzelm
parents: 24867
diff changeset
    37
val add = Thm.declaration_attribute add_thm;
9d95309f8069 export add/del_thm;
wenzelm
parents: 24867
diff changeset
    38
val del = Thm.declaration_attribute del_thm;
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    39
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    40
val setup =
30528
7173bf123335 simplified attribute setup;
wenzelm
parents: 29579
diff changeset
    41
  Attrib.setup (Binding.name name) (Attrib.add_del add del) ("declaration of " ^ description) #>
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 36296
diff changeset
    42
  Global_Theory.add_thms_dynamic (Binding.name name, content);
24047
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    43
47b588ce11ec Named collections of theorems in canonical order.
wenzelm
parents:
diff changeset
    44
end;