src/HOL/Library/Function_Algebras.thy
changeset 60500 903bb1495239
parent 59815 cce82e360c2f
child 60562 24af00b010cf
equal deleted inserted replaced
60499:54a3db2ed201 60500:903bb1495239
     1 (*  Title:      HOL/Library/Function_Algebras.thy
     1 (*  Title:      HOL/Library/Function_Algebras.thy
     2     Author:     Jeremy Avigad and Kevin Donnelly; Florian Haftmann, TUM
     2     Author:     Jeremy Avigad and Kevin Donnelly; Florian Haftmann, TUM
     3 *)
     3 *)
     4 
     4 
     5 section {* Pointwise instantiation of functions to algebra type classes *}
     5 section \<open>Pointwise instantiation of functions to algebra type classes\<close>
     6 
     6 
     7 theory Function_Algebras
     7 theory Function_Algebras
     8 imports Main
     8 imports Main
     9 begin
     9 begin
    10 
    10 
    11 text {* Pointwise operations *}
    11 text \<open>Pointwise operations\<close>
    12 
    12 
    13 instantiation "fun" :: (type, plus) plus
    13 instantiation "fun" :: (type, plus) plus
    14 begin
    14 begin
    15 
    15 
    16 definition "f + g = (\<lambda>x. f x + g x)"
    16 definition "f + g = (\<lambda>x. f x + g x)"
    57 lemma one_fun_apply [simp]:
    57 lemma one_fun_apply [simp]:
    58   "1 x = 1"
    58   "1 x = 1"
    59   by (simp add: one_fun_def)
    59   by (simp add: one_fun_def)
    60 
    60 
    61 
    61 
    62 text {* Additive structures *}
    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 default (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
    87 
    87 
    88 instance "fun" :: (type, ab_group_add) ab_group_add
    88 instance "fun" :: (type, ab_group_add) ab_group_add
    89   by default simp_all
    89   by default simp_all
    90 
    90 
    91 
    91 
    92 text {* Multiplicative structures *}
    92 text \<open>Multiplicative structures\<close>
    93 
    93 
    94 instance "fun" :: (type, semigroup_mult) semigroup_mult
    94 instance "fun" :: (type, semigroup_mult) semigroup_mult
    95   by default (simp add: fun_eq_iff mult.assoc)
    95   by default (simp add: fun_eq_iff mult.assoc)
    96 
    96 
    97 instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult
    97 instance "fun" :: (type, ab_semigroup_mult) ab_semigroup_mult
   102 
   102 
   103 instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult
   103 instance "fun" :: (type, comm_monoid_mult) comm_monoid_mult
   104   by default simp
   104   by default simp
   105 
   105 
   106 
   106 
   107 text {* Misc *}
   107 text \<open>Misc\<close>
   108 
   108 
   109 instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
   109 instance "fun" :: (type, "Rings.dvd") "Rings.dvd" ..
   110 
   110 
   111 instance "fun" :: (type, mult_zero) mult_zero
   111 instance "fun" :: (type, mult_zero) mult_zero
   112   by default (simp_all add: fun_eq_iff)
   112   by default (simp_all add: fun_eq_iff)
   113 
   113 
   114 instance "fun" :: (type, zero_neq_one) zero_neq_one
   114 instance "fun" :: (type, zero_neq_one) zero_neq_one
   115   by default (simp add: fun_eq_iff)
   115   by default (simp add: fun_eq_iff)
   116 
   116 
   117 
   117 
   118 text {* Ring structures *}
   118 text \<open>Ring structures\<close>
   119 
   119 
   120 instance "fun" :: (type, semiring) semiring
   120 instance "fun" :: (type, semiring) semiring
   121   by default (simp_all add: fun_eq_iff algebra_simps)
   121   by default (simp_all add: fun_eq_iff algebra_simps)
   122 
   122 
   123 instance "fun" :: (type, comm_semiring) comm_semiring
   123 instance "fun" :: (type, comm_semiring) comm_semiring
   174 instance "fun" :: (type, comm_ring_1) comm_ring_1 ..
   174 instance "fun" :: (type, comm_ring_1) comm_ring_1 ..
   175 
   175 
   176 instance "fun" :: (type, ring_char_0) ring_char_0 ..
   176 instance "fun" :: (type, ring_char_0) ring_char_0 ..
   177 
   177 
   178 
   178 
   179 text {* Ordered structures *}
   179 text \<open>Ordered structures\<close>
   180 
   180 
   181 instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
   181 instance "fun" :: (type, ordered_ab_semigroup_add) ordered_ab_semigroup_add
   182   by default (auto simp add: le_fun_def intro: add_left_mono)
   182   by default (auto simp add: le_fun_def intro: add_left_mono)
   183 
   183 
   184 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 ..