src/HOL/Tools/inductive_package.ML
changeset 8634 3f34637cb9c0
parent 8433 8ae16c770fc8
child 8720 840c75ab2a7f
equal deleted inserted replaced
8633:427ead639d8a 8634:3f34637cb9c0
   122     else if can (HOLogic.dest_eq o HOLogic.dest_Trueprop) concl then
   122     else if can (HOLogic.dest_eq o HOLogic.dest_Trueprop) concl then
   123       eq2mono thm
   123       eq2mono thm
   124     else [thm]
   124     else [thm]
   125   end;
   125   end;
   126 
   126 
   127 (* mono add/del *)
   127 
       
   128 (* attributes *)
   128 
   129 
   129 local
   130 local
   130 
   131 
   131 fun map_rules_global f thy = put_monos (f (get_monos thy)) thy;
   132 fun map_rules_global f thy = put_monos (f (get_monos thy)) thy;
   132 
   133 
   134 fun del_mono thm rules = Library.gen_rems Thm.eq_thm (rules, mk_mono thm);
   135 fun del_mono thm rules = Library.gen_rems Thm.eq_thm (rules, mk_mono thm);
   135 
   136 
   136 fun mk_att f g (x, thm) = (f (g thm) x, thm);
   137 fun mk_att f g (x, thm) = (f (g thm) x, thm);
   137 
   138 
   138 in
   139 in
   139 
   140   val mono_add_global = mk_att map_rules_global add_mono;
   140 val mono_add_global = mk_att map_rules_global add_mono;
   141   val mono_del_global = mk_att map_rules_global del_mono;
   141 val mono_del_global = mk_att map_rules_global del_mono;
       
   142 
       
   143 end;
   142 end;
   144 
   143 
   145 
       
   146 (* concrete syntax *)
       
   147 
       
   148 val monoN = "mono";
       
   149 val addN = "add";
       
   150 val delN = "del";
       
   151 
       
   152 fun mono_att add del =
       
   153   Attrib.syntax (Scan.lift (Args.$$$ addN >> K add || Args.$$$ delN >> K del || Scan.succeed add));
       
   154 
       
   155 val mono_attr =
   144 val mono_attr =
   156   (mono_att mono_add_global mono_del_global, mono_att Attrib.undef_local_attribute Attrib.undef_local_attribute);
   145  (Attrib.add_del_args mono_add_global mono_del_global,
       
   146   Attrib.add_del_args Attrib.undef_local_attribute Attrib.undef_local_attribute);
   157 
   147 
   158 
   148 
   159 
   149 
   160 (** utilities **)
   150 (** utilities **)
   161 
   151 
   822 
   812 
   823 (** package setup **)
   813 (** package setup **)
   824 
   814 
   825 (* setup theory *)
   815 (* setup theory *)
   826 
   816 
   827 val setup = [InductiveData.init,
   817 val setup =
   828              Attrib.add_attributes [(monoN, mono_attr, "monotonicity rule")]];
   818  [InductiveData.init,
       
   819   Attrib.add_attributes [("mono", mono_attr, "monotonicity rule")]];
   829 
   820 
   830 
   821 
   831 (* outer syntax *)
   822 (* outer syntax *)
   832 
   823 
   833 local structure P = OuterParse and K = OuterSyntax.Keyword in
   824 local structure P = OuterParse and K = OuterSyntax.Keyword in