src/Pure/Tools/nbe.ML
changeset 22846 fb79144af9a3
parent 22728 ecbbdf50df2f
child 22902 ac833b4bb7ee
equal deleted inserted replaced
22845:5f9138bcb3d7 22846:fb79144af9a3
    24 (** data setup **)
    24 (** data setup **)
    25 
    25 
    26 (* preproc and postproc attributes *)
    26 (* preproc and postproc attributes *)
    27 
    27 
    28 structure NBE_Rewrite = TheoryDataFun
    28 structure NBE_Rewrite = TheoryDataFun
    29 (struct
    29 (
    30   val name = "Pure/nbe";
       
    31   type T = thm list * thm list
    30   type T = thm list * thm list
    32 
    31   val empty = ([], []);
    33   val empty = ([],[])
       
    34   val copy = I;
    32   val copy = I;
    35   val extend = I;
    33   val extend = I;
    36 
       
    37   fun merge _ ((pres1,posts1), (pres2,posts2)) =
    34   fun merge _ ((pres1,posts1), (pres2,posts2)) =
    38     (Library.merge Thm.eq_thm (pres1,pres2), Library.merge Thm.eq_thm (posts1,posts2))
    35     (Library.merge Thm.eq_thm (pres1,pres2), Library.merge Thm.eq_thm (posts1,posts2))
    39 
    36 );
    40   fun print _ _ = ()
       
    41 end);
       
    42 
    37 
    43 val _ =
    38 val _ =
    44   let
    39   let
    45     fun map_data f = Context.mapping (NBE_Rewrite.map f) I;
    40     fun map_data f = Context.mapping (NBE_Rewrite.map f) I;
    46     fun attr_pre (thy, thm) =
    41     fun attr_pre (thy, thm) =
    49       ((map_data o apsnd) (insert Thm.eq_thm thm) thy, thm)
    44       ((map_data o apsnd) (insert Thm.eq_thm thm) thy, thm)
    50     val attr = Attrib.syntax (Scan.lift (Args.$$$ "pre" >> K attr_pre
    45     val attr = Attrib.syntax (Scan.lift (Args.$$$ "pre" >> K attr_pre
    51       || Args.$$$ "post" >> K attr_post));
    46       || Args.$$$ "post" >> K attr_post));
    52   in
    47   in
    53     Context.add_setup (
    48     Context.add_setup (
    54       NBE_Rewrite.init
    49       Attrib.add_attributes
    55       #> Attrib.add_attributes
       
    56           [("normal", attr, "declare rewrite theorems for normalization")]
    50           [("normal", attr, "declare rewrite theorems for normalization")]
    57     )
    51     )
    58   end;
    52   end;
    59 
    53 
    60 fun the_pres thy =
    54 fun the_pres thy =