src/HOL/ex/reflection_data.ML
changeset 23606 60950b22dcbf
parent 23545 2fddae6056ab
child 23647 89286c4e7928
equal deleted inserted replaced
23605:81d0fdec9edc 23606:60950b22dcbf
     7 
     7 
     8 signature REIFY_DATA =
     8 signature REIFY_DATA =
     9 sig
     9 sig
    10   type entry
    10   type entry
    11   val get: Proof.context -> entry
    11   val get: Proof.context -> entry
    12   val del: thm list -> attribute
    12   val del: attribute
    13   val add: thm list -> attribute 
    13   val add: attribute 
    14   val setup: theory -> theory
    14   val setup: theory -> theory
    15 end;
    15 end;
    16 
    16 
    17 structure Reify_Data : REIFY_DATA =
    17 structure Reify_Data : REIFY_DATA =
    18 struct
    18 struct
    26   val extend = I
    26   val extend = I
    27   fun merge _ = Library.merge Thm.eq_thm);
    27   fun merge _ = Library.merge Thm.eq_thm);
    28 
    28 
    29 val get = Data.get o Context.Proof;
    29 val get = Data.get o Context.Proof;
    30 
    30 
    31 fun add ths = Thm.declaration_attribute (fn th => fn context => 
    31 val add = Thm.declaration_attribute (fn th => fn context => 
    32   context |> Data.map (fn x => merge Thm.eq_thm (x,ths)))
    32   context |> Data.map (Drule.add_rule th ))
    33 
    33 
    34 fun del ths = Thm.declaration_attribute (fn th => fn context => 
    34 val del = Thm.declaration_attribute (fn th => fn context => 
    35   context |> Data.map (fn x => subtract Thm.eq_thm x ths))
    35   context |> Data.map (Drule.del_rule th ))
    36 
    36 
    37 (* concrete syntax *)
    37 (* concrete syntax *)
       
    38 (*
    38 local
    39 local
    39 fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
    40 fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
    40 
    41 
    41 val constsN = "consts";
    42 val constsN = "consts";
    42 val addN = "add";
    43 val addN = "add";
    50 in
    51 in
    51 fun att_syntax src = src |> Attrib.syntax
    52 fun att_syntax src = src |> Attrib.syntax
    52  ((Scan.lift (Args.$$$ "del") |-- thms) >> del ||
    53  ((Scan.lift (Args.$$$ "del") |-- thms) >> del ||
    53   optional (keyword addN |-- thms) >> add)
    54   optional (keyword addN |-- thms) >> add)
    54 end;
    55 end;
    55 
    56 *)
    56 
    57 
    57 (* theory setup *)
    58 (* theory setup *)
    58  val setup =
    59  val setup =
    59   Attrib.add_attributes [("reify", att_syntax, "Reify data")];
    60   Attrib.add_attributes [("reify", Attrib.add_del_args add del, "Reify data")];
    60 end;
    61 end;