23545
|
1 |
(* Title: HOL/ex/reflection_data.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Amine Chaieb, TU Muenchen
|
|
4 |
|
|
5 |
Data for the reification and reflection Methods
|
|
6 |
*)
|
|
7 |
|
|
8 |
signature REIFY_DATA =
|
|
9 |
sig
|
|
10 |
type entry
|
|
11 |
val get: Proof.context -> entry
|
23606
|
12 |
val del: attribute
|
|
13 |
val add: attribute
|
23545
|
14 |
val setup: theory -> theory
|
|
15 |
end;
|
|
16 |
|
|
17 |
structure Reify_Data : REIFY_DATA =
|
|
18 |
struct
|
|
19 |
|
|
20 |
type entry = thm list;
|
|
21 |
|
|
22 |
structure Data = GenericDataFun
|
|
23 |
( val name = "Reify-Data";
|
|
24 |
type T = thm list
|
|
25 |
val empty = [];
|
|
26 |
val extend = I
|
|
27 |
fun merge _ = Library.merge Thm.eq_thm);
|
|
28 |
|
|
29 |
val get = Data.get o Context.Proof;
|
|
30 |
|
23606
|
31 |
val add = Thm.declaration_attribute (fn th => fn context =>
|
|
32 |
context |> Data.map (Drule.add_rule th ))
|
23545
|
33 |
|
23606
|
34 |
val del = Thm.declaration_attribute (fn th => fn context =>
|
|
35 |
context |> Data.map (Drule.del_rule th ))
|
23545
|
36 |
|
|
37 |
(* concrete syntax *)
|
23606
|
38 |
(*
|
23545
|
39 |
local
|
|
40 |
fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
|
|
41 |
|
|
42 |
val constsN = "consts";
|
|
43 |
val addN = "add";
|
|
44 |
val delN = "del";
|
|
45 |
val any_keyword = keyword constsN || keyword addN || keyword delN;
|
|
46 |
val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
|
|
47 |
val terms = thms >> map (term_of o Drule.dest_term);
|
|
48 |
|
|
49 |
fun optional scan = Scan.optional scan [];
|
|
50 |
|
|
51 |
in
|
|
52 |
fun att_syntax src = src |> Attrib.syntax
|
|
53 |
((Scan.lift (Args.$$$ "del") |-- thms) >> del ||
|
|
54 |
optional (keyword addN |-- thms) >> add)
|
|
55 |
end;
|
23606
|
56 |
*)
|
23545
|
57 |
|
|
58 |
(* theory setup *)
|
|
59 |
val setup =
|
23606
|
60 |
Attrib.add_attributes [("reify", Attrib.add_del_args add del, "Reify data")];
|
23545
|
61 |
end;
|