src/HOL/Tools/inductive_package.ML
changeset 9831 9b883c416aef
parent 9804 ee0c337327cf
child 9893 93d2fde0306c
equal deleted inserted replaced
9830:e4ad74159b43 9831:9b883c416aef
   107 
   107 
   108 
   108 
   109 
   109 
   110 (** monotonicity rules **)
   110 (** monotonicity rules **)
   111 
   111 
   112 val get_monos = snd o InductiveData.get;
   112 val get_monos = #2 o InductiveData.get;
   113 fun put_monos thms thy = InductiveData.put (fst (InductiveData.get thy), thms) thy;
   113 fun map_monos f = InductiveData.map (Library.apsnd f);
   114 
   114 
   115 fun mk_mono thm =
   115 fun mk_mono thm =
   116   let
   116   let
   117     fun eq2mono thm' = [standard (thm' RS (thm' RS eq_to_mono))] @
   117     fun eq2mono thm' = [standard (thm' RS (thm' RS eq_to_mono))] @
   118       (case concl_of thm of
   118       (case concl_of thm of
   128   end;
   128   end;
   129 
   129 
   130 
   130 
   131 (* attributes *)
   131 (* attributes *)
   132 
   132 
   133 local
   133 fun mono_add_global (thy, thm) = (map_monos (Drule.add_rules (mk_mono thm)) thy, thm);
   134 
   134 fun mono_del_global (thy, thm) = (map_monos (Drule.del_rules (mk_mono thm)) thy, thm);
   135 fun map_rules_global f thy = put_monos (f (get_monos thy)) thy;
       
   136 
       
   137 fun add_mono thm rules = Library.gen_union Thm.eq_thm (mk_mono thm, rules);
       
   138 fun del_mono thm rules = Library.gen_rems Thm.eq_thm (rules, mk_mono thm);
       
   139 
       
   140 fun mk_att f g (x, thm) = (f (g thm) x, thm);
       
   141 
       
   142 in
       
   143   val mono_add_global = mk_att map_rules_global add_mono;
       
   144   val mono_del_global = mk_att map_rules_global del_mono;
       
   145 end;
       
   146 
   135 
   147 val mono_attr =
   136 val mono_attr =
   148  (Attrib.add_del_args mono_add_global mono_del_global,
   137  (Attrib.add_del_args mono_add_global mono_del_global,
   149   Attrib.add_del_args Attrib.undef_local_attribute Attrib.undef_local_attribute);
   138   Attrib.add_del_args Attrib.undef_local_attribute Attrib.undef_local_attribute);
   150 
   139