src/HOL/Library/Function_Algebras.thy
changeset 60679 ade12ef2773c
parent 60562 24af00b010cf
child 62376 85f38d5f8807
equal deleted inserted replaced
60678:17ba2df56dee 60679:ade12ef2773c
    60 
    60 
    61 
    61 
    62 text \<open>Additive structures\<close>
    62 text \<open>Additive structures\<close>
    63 
    63 
    64 instance "fun" :: (type, semigroup_add) semigroup_add
    64 instance "fun" :: (type, semigroup_add) semigroup_add
    65   by default (simp add: fun_eq_iff add.assoc)
    65   by standard (simp add: fun_eq_iff add.assoc)
    66 
    66 
    67 instance "fun" :: (type, cancel_semigroup_add) cancel_semigroup_add
    67 instance "fun" :: (type, cancel_semigroup_add) cancel_semigroup_add
    68   by default (simp_all add: fun_eq_iff)
    68   by standard (simp_all add: fun_eq_iff)
    69 
    69 
    70 instance "fun" :: (type, ab_semigroup_add) ab_semigroup_add
    70 instance "fun" :: (type, ab_semigroup_add) ab_semigroup_add
    71   by default (simp add: fun_eq_iff add.commute)
    71   by standard (simp add: fun_eq_iff add.commute)
    72 
    72 
    73 instance "fun" :: (type, cancel_ab_semigroup_add) cancel_ab_semigroup_add
    73 instance "fun" :: (type, cancel_ab_semigroup_add) cancel_ab_semigroup_add
    74   by default (simp_all add: fun_eq_iff diff_diff_eq)
    74   by standard (simp_all add: fun_eq_iff diff_diff_eq)
    75 
    75 
    76 instance "fun" :: (type, monoid_add) monoid_add
    76 instance "fun" :: (type, monoid_add) monoid_add
    77   by default (simp_all add: fun_eq_iff)
    77   by standard (simp_all add: fun_eq_iff)
    78 
    78 
    79 instance "fun" :: (type, comm_monoid_add) comm_monoid_add
    79 instance "fun" :: (type, comm_monoid_add) comm_monoid_add
    80   by default simp
    80   by standard simp
    81 
    81 
    82 instance "fun" :: (type, cancel_comm_monoid_add) cancel_comm_monoid_add ..
    82 instance "fun" :: (type, cancel_comm_monoid_add) cancel_comm_monoid_add ..
    83 
    83 
    84 instance "fun" :: (type, group_add) group_add
    84 instance "fun" :: (type, group_add) group_add
    85   by default
    85   by standard (simp_all add: fun_eq_iff)
    86     (simp_all add: fun_eq_iff)
       
    87 
    86 
    88 instance "fun" :: (type, ab_group_add) ab_group_add
    87 instance "fun" :: (type, ab_group_add) ab_group_add
    89   by default simp_all
    88   by standard simp_all
    90 
    89 
    91 
    90 
    92 text \<open>Multiplicative structures\<close>
    91 text \<open>Multiplicative structures\<close>
    93 
    92 
    94 instance "fun" :: (type, semigroup_mult) semigroup_mult
    93 instance "fun" :: (type, semigroup_mult) semigroup_mult
    95   by default (simp add: fun_eq_iff mult.assoc)
    94   by standard (simp add: fun_eq_iff mult.assoc)
    96 
    95 
    97 instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult
    96 instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult
    98   by default (simp add: fun_eq_iff mult.commute)
    97   by standard (simp add: fun_eq_iff mult.commute)
    99 
    98 
   100 instance "fun" :: (type, monoid_mult) monoid_mult
    99 instance "fun" :: (type, monoid_mult) monoid_mult
   101   by default (simp_all add: fun_eq_iff)
   100   by standard (simp_all add: fun_eq_iff)
   102 
   101 
   103 instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult
   102 instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult
   104   by default simp
   103   by standard simp
   105 
   104 
   106 
   105 
   107 text \<open>Misc\<close>
   106 text \<open>Misc\<close>
   108 
   107 
   109 instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
   108 instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
   110 
   109 
   111 instance "fun" :: (type, mult_zero) mult_zero
   110 instance "fun" :: (type, mult_zero) mult_zero
   112   by default (simp_all add: fun_eq_iff)
   111   by standard (simp_all add: fun_eq_iff)
   113 
   112 
   114 instance "fun" :: (type, zero_neq_one) zero_neq_one
   113 instance "fun" :: (type, zero_neq_one) zero_neq_one
   115   by default (simp add: fun_eq_iff)
   114   by standard (simp add: fun_eq_iff)
   116 
   115 
   117 
   116 
   118 text \<open>Ring structures\<close>
   117 text \<open>Ring structures\<close>
   119 
   118 
   120 instance "fun" :: (type, semiring) semiring
   119 instance "fun" :: (type, semiring) semiring
   121   by default (simp_all add: fun_eq_iff algebra_simps)
   120   by standard (simp_all add: fun_eq_iff algebra_simps)
   122 
   121 
   123 instance "fun" :: (type, comm_semiring) comm_semiring
   122 instance "fun" :: (type, comm_semiring) comm_semiring
   124   by default (simp add: fun_eq_iff  algebra_simps)
   123   by standard (simp add: fun_eq_iff  algebra_simps)
   125 
   124 
   126 instance "fun" :: (type, semiring_0) semiring_0 ..
   125 instance "fun" :: (type, semiring_0) semiring_0 ..
   127 
   126 
   128 instance "fun" :: (type, comm_semiring_0) comm_semiring_0 ..
   127 instance "fun" :: (type, comm_semiring_0) comm_semiring_0 ..
   129 
   128 
   153 instance "fun" :: (type, comm_semiring_1) comm_semiring_1 ..
   152 instance "fun" :: (type, comm_semiring_1) comm_semiring_1 ..
   154 
   153 
   155 instance "fun" :: (type, semiring_1_cancel) semiring_1_cancel ..
   154 instance "fun" :: (type, semiring_1_cancel) semiring_1_cancel ..
   156 
   155 
   157 instance "fun" :: (type, comm_semiring_1_cancel) comm_semiring_1_cancel 
   156 instance "fun" :: (type, comm_semiring_1_cancel) comm_semiring_1_cancel 
   158   by default (auto simp add: times_fun_def algebra_simps)
   157   by standard (auto simp add: times_fun_def algebra_simps)
   159 
   158 
   160 instance "fun" :: (type, semiring_char_0) semiring_char_0
   159 instance "fun" :: (type, semiring_char_0) semiring_char_0
   161 proof
   160 proof
   162   from inj_of_nat have "inj (\<lambda>n (x::'a). of_nat n :: 'b)"
   161   from inj_of_nat have "inj (\<lambda>n (x::'a). of_nat n :: 'b)"
   163     by (rule inj_fun)
   162     by (rule inj_fun)
   178 
   177 
   179 
   178 
   180 text \<open>Ordered structures\<close>
   179 text \<open>Ordered structures\<close>
   181 
   180 
   182 instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
   181 instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
   183   by default (auto simp add: le_fun_def intro: add_left_mono)
   182   by standard (auto simp add: le_fun_def intro: add_left_mono)
   184 
   183 
   185 instance "fun" :: (type, ordered_cancel_ab_semigroup_add) ordered_cancel_ab_semigroup_add ..
   184 instance "fun" :: (type, ordered_cancel_ab_semigroup_add) ordered_cancel_ab_semigroup_add ..
   186 
   185 
   187 instance "fun" :: (type, ordered_ab_semigroup_add_imp_le) ordered_ab_semigroup_add_imp_le
   186 instance "fun" :: (type, ordered_ab_semigroup_add_imp_le) ordered_ab_semigroup_add_imp_le
   188   by default (simp add: le_fun_def)
   187   by standard (simp add: le_fun_def)
   189 
   188 
   190 instance "fun" :: (type, ordered_comm_monoid_add) ordered_comm_monoid_add ..
   189 instance "fun" :: (type, ordered_comm_monoid_add) ordered_comm_monoid_add ..
   191 
   190 
   192 instance "fun" :: (type, ordered_ab_group_add) ordered_ab_group_add ..
   191 instance "fun" :: (type, ordered_ab_group_add) ordered_ab_group_add ..
   193 
   192 
   194 instance "fun" :: (type, ordered_semiring) ordered_semiring
   193 instance "fun" :: (type, ordered_semiring) ordered_semiring
   195   by default
   194   by standard (auto simp add: le_fun_def intro: mult_left_mono mult_right_mono)
   196     (auto simp add: le_fun_def intro: mult_left_mono mult_right_mono)
       
   197 
   195 
   198 instance "fun" :: (type, ordered_comm_semiring) ordered_comm_semiring
   196 instance "fun" :: (type, ordered_comm_semiring) ordered_comm_semiring
   199   by default (fact mult_left_mono)
   197   by standard (fact mult_left_mono)
   200 
   198 
   201 instance "fun" :: (type, ordered_cancel_semiring) ordered_cancel_semiring ..
   199 instance "fun" :: (type, ordered_cancel_semiring) ordered_cancel_semiring ..
   202 
   200 
   203 instance "fun" :: (type, ordered_cancel_comm_semiring) ordered_cancel_comm_semiring ..
   201 instance "fun" :: (type, ordered_cancel_comm_semiring) ordered_cancel_comm_semiring ..
   204 
   202