src/HOL/Algebra/CRing.thy
author ballarin
Wed Jul 19 19:25:58 2006 +0200 (2006-07-19)
changeset 20168 ed7bced29e1b
parent 19981 c0f124a0d385
permissions -rw-r--r--
Reimplemented algebra method; now controlled by attribute.
ballarin@13835
     1
(*
ballarin@13835
     2
  Title:     The algebraic hierarchy of rings
ballarin@13835
     3
  Id:        $Id$
ballarin@13835
     4
  Author:    Clemens Ballarin, started 9 December 1996
ballarin@13835
     5
  Copyright: Clemens Ballarin
ballarin@13835
     6
*)
ballarin@13835
     7
wenzelm@14577
     8
header {* Abelian Groups *}
wenzelm@14577
     9
haftmann@16417
    10
theory CRing imports FiniteProduct
haftmann@16417
    11
uses ("ringsimp.ML") begin
ballarin@13835
    12
ballarin@13936
    13
record 'a ring = "'a monoid" +
ballarin@13936
    14
  zero :: 'a ("\<zero>\<index>")
ballarin@13936
    15
  add :: "['a, 'a] => 'a" (infixl "\<oplus>\<index>" 65)
ballarin@13936
    16
ballarin@13936
    17
text {* Derived operations. *}
ballarin@13936
    18
wenzelm@14651
    19
constdefs (structure R)
ballarin@15095
    20
  a_inv :: "[('a, 'm) ring_scheme, 'a ] => 'a" ("\<ominus>\<index> _" [81] 80)
ballarin@13936
    21
  "a_inv R == m_inv (| carrier = carrier R, mult = add R, one = zero R |)"
ballarin@13936
    22
haftmann@19233
    23
  a_minus :: "[('a, 'm) ring_scheme, 'a, 'a] => 'a" (infixl "\<ominus>\<index>" 65)
wenzelm@14651
    24
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<ominus> y == x \<oplus> (\<ominus> y)"
ballarin@13936
    25
ballarin@19783
    26
locale abelian_monoid =
ballarin@19783
    27
  fixes G (structure)
paulson@14963
    28
  assumes a_comm_monoid:
paulson@14963
    29
     "comm_monoid (| carrier = carrier G, mult = add G, one = zero G |)"
paulson@14963
    30
ballarin@13936
    31
ballarin@13936
    32
text {*
ballarin@13936
    33
  The following definition is redundant but simple to use.
ballarin@13936
    34
*}
ballarin@13936
    35
ballarin@13936
    36
locale abelian_group = abelian_monoid +
paulson@14963
    37
  assumes a_comm_group:
paulson@14963
    38
     "comm_group (| carrier = carrier G, mult = add G, one = zero G |)"
paulson@14963
    39
ballarin@13936
    40
ballarin@13936
    41
subsection {* Basic Properties *}
ballarin@13936
    42
ballarin@13936
    43
lemma abelian_monoidI:
ballarin@19783
    44
  fixes R (structure)
ballarin@13936
    45
  assumes a_closed:
ballarin@15095
    46
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
ballarin@15095
    47
    and zero_closed: "\<zero> \<in> carrier R"
ballarin@13936
    48
    and a_assoc:
ballarin@13936
    49
      "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
ballarin@15095
    50
      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
ballarin@15095
    51
    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
ballarin@13936
    52
    and a_comm:
ballarin@15095
    53
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
ballarin@13936
    54
  shows "abelian_monoid R"
ballarin@13936
    55
  by (auto intro!: abelian_monoid.intro comm_monoidI intro: prems)
ballarin@13936
    56
ballarin@13936
    57
lemma abelian_groupI:
ballarin@19783
    58
  fixes R (structure)
ballarin@13936
    59
  assumes a_closed:
ballarin@15095
    60
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
ballarin@13936
    61
    and zero_closed: "zero R \<in> carrier R"
ballarin@13936
    62
    and a_assoc:
ballarin@13936
    63
      "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
ballarin@15095
    64
      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
ballarin@13936
    65
    and a_comm:
ballarin@15095
    66
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
ballarin@15095
    67
    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
ballarin@15095
    68
    and l_inv_ex: "!!x. x \<in> carrier R ==> EX y : carrier R. y \<oplus> x = \<zero>"
ballarin@13936
    69
  shows "abelian_group R"
ballarin@13936
    70
  by (auto intro!: abelian_group.intro abelian_monoidI
ballarin@13936
    71
      abelian_group_axioms.intro comm_monoidI comm_groupI
ballarin@13936
    72
    intro: prems)
ballarin@13936
    73
ballarin@13936
    74
lemma (in abelian_monoid) a_monoid:
ballarin@13936
    75
  "monoid (| carrier = carrier G, mult = add G, one = zero G |)"
paulson@14963
    76
by (rule comm_monoid.axioms, rule a_comm_monoid) 
ballarin@13936
    77
ballarin@13936
    78
lemma (in abelian_group) a_group:
ballarin@13936
    79
  "group (| carrier = carrier G, mult = add G, one = zero G |)"
ballarin@19931
    80
  by (simp add: group_def a_monoid)
ballarin@19931
    81
    (simp add: comm_group.axioms group.axioms a_comm_group)
ballarin@13936
    82
paulson@14963
    83
lemmas monoid_record_simps = partial_object.simps monoid.simps
ballarin@13936
    84
ballarin@13936
    85
lemma (in abelian_monoid) a_closed [intro, simp]:
paulson@14963
    86
  "\<lbrakk> x \<in> carrier G; y \<in> carrier G \<rbrakk> \<Longrightarrow> x \<oplus> y \<in> carrier G"
paulson@14963
    87
  by (rule monoid.m_closed [OF a_monoid, simplified monoid_record_simps]) 
ballarin@13936
    88
ballarin@13936
    89
lemma (in abelian_monoid) zero_closed [intro, simp]:
ballarin@13936
    90
  "\<zero> \<in> carrier G"
ballarin@13936
    91
  by (rule monoid.one_closed [OF a_monoid, simplified monoid_record_simps])
ballarin@13936
    92
ballarin@13936
    93
lemma (in abelian_group) a_inv_closed [intro, simp]:
ballarin@13936
    94
  "x \<in> carrier G ==> \<ominus> x \<in> carrier G"
ballarin@13936
    95
  by (simp add: a_inv_def
ballarin@13936
    96
    group.inv_closed [OF a_group, simplified monoid_record_simps])
ballarin@13936
    97
ballarin@13936
    98
lemma (in abelian_group) minus_closed [intro, simp]:
ballarin@13936
    99
  "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<ominus> y \<in> carrier G"
haftmann@19233
   100
  by (simp add: a_minus_def)
ballarin@13936
   101
ballarin@13936
   102
lemma (in abelian_group) a_l_cancel [simp]:
ballarin@13936
   103
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13936
   104
   (x \<oplus> y = x \<oplus> z) = (y = z)"
ballarin@13936
   105
  by (rule group.l_cancel [OF a_group, simplified monoid_record_simps])
ballarin@13936
   106
ballarin@13936
   107
lemma (in abelian_group) a_r_cancel [simp]:
ballarin@13936
   108
  "[| x \<in> carrier G; y \<in> carrier G; z \<in> carrier G |] ==>
ballarin@13936
   109
   (y \<oplus> x = z \<oplus> x) = (y = z)"
ballarin@13936
   110
  by (rule group.r_cancel [OF a_group, simplified monoid_record_simps])
ballarin@13936
   111
ballarin@13936
   112
lemma (in abelian_monoid) a_assoc:
paulson@14963
   113
  "\<lbrakk>x \<in> carrier G; y \<in> carrier G; z \<in> carrier G\<rbrakk> \<Longrightarrow>
ballarin@13936
   114
  (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
paulson@14963
   115
  by (rule monoid.m_assoc [OF a_monoid, simplified monoid_record_simps])
ballarin@13936
   116
ballarin@13936
   117
lemma (in abelian_monoid) l_zero [simp]:
ballarin@13936
   118
  "x \<in> carrier G ==> \<zero> \<oplus> x = x"
ballarin@13936
   119
  by (rule monoid.l_one [OF a_monoid, simplified monoid_record_simps])
ballarin@13936
   120
ballarin@13936
   121
lemma (in abelian_group) l_neg:
ballarin@13936
   122
  "x \<in> carrier G ==> \<ominus> x \<oplus> x = \<zero>"
ballarin@13936
   123
  by (simp add: a_inv_def
ballarin@13936
   124
    group.l_inv [OF a_group, simplified monoid_record_simps])
ballarin@13936
   125
ballarin@13936
   126
lemma (in abelian_monoid) a_comm:
paulson@14963
   127
  "\<lbrakk>x \<in> carrier G; y \<in> carrier G\<rbrakk> \<Longrightarrow> x \<oplus> y = y \<oplus> x"
paulson@14963
   128
  by (rule comm_monoid.m_comm [OF a_comm_monoid,
ballarin@13936
   129
    simplified monoid_record_simps])
ballarin@13936
   130
ballarin@13936
   131
lemma (in abelian_monoid) a_lcomm:
paulson@14963
   132
  "\<lbrakk>x \<in> carrier G; y \<in> carrier G; z \<in> carrier G\<rbrakk> \<Longrightarrow>
ballarin@13936
   133
   x \<oplus> (y \<oplus> z) = y \<oplus> (x \<oplus> z)"
paulson@14963
   134
  by (rule comm_monoid.m_lcomm [OF a_comm_monoid,
paulson@14963
   135
                                simplified monoid_record_simps])
ballarin@13936
   136
ballarin@13936
   137
lemma (in abelian_monoid) r_zero [simp]:
ballarin@13936
   138
  "x \<in> carrier G ==> x \<oplus> \<zero> = x"
ballarin@13936
   139
  using monoid.r_one [OF a_monoid]
ballarin@13936
   140
  by simp
ballarin@13936
   141
ballarin@13936
   142
lemma (in abelian_group) r_neg:
ballarin@13936
   143
  "x \<in> carrier G ==> x \<oplus> (\<ominus> x) = \<zero>"
ballarin@13936
   144
  using group.r_inv [OF a_group]
ballarin@13936
   145
  by (simp add: a_inv_def)
ballarin@13936
   146
ballarin@13936
   147
lemma (in abelian_group) minus_zero [simp]:
ballarin@13936
   148
  "\<ominus> \<zero> = \<zero>"
ballarin@13936
   149
  by (simp add: a_inv_def
ballarin@13936
   150
    group.inv_one [OF a_group, simplified monoid_record_simps])
ballarin@13936
   151
ballarin@13936
   152
lemma (in abelian_group) minus_minus [simp]:
ballarin@13936
   153
  "x \<in> carrier G ==> \<ominus> (\<ominus> x) = x"
ballarin@13936
   154
  using group.inv_inv [OF a_group, simplified monoid_record_simps]
ballarin@13936
   155
  by (simp add: a_inv_def)
ballarin@13936
   156
ballarin@13936
   157
lemma (in abelian_group) a_inv_inj:
ballarin@13936
   158
  "inj_on (a_inv G) (carrier G)"
ballarin@13936
   159
  using group.inv_inj [OF a_group, simplified monoid_record_simps]
ballarin@13936
   160
  by (simp add: a_inv_def)
ballarin@13936
   161
ballarin@13936
   162
lemma (in abelian_group) minus_add:
ballarin@13936
   163
  "[| x \<in> carrier G; y \<in> carrier G |] ==> \<ominus> (x \<oplus> y) = \<ominus> x \<oplus> \<ominus> y"
ballarin@13936
   164
  using comm_group.inv_mult [OF a_comm_group]
ballarin@13936
   165
  by (simp add: a_inv_def)
ballarin@13936
   166
ballarin@19981
   167
lemma (in abelian_group) minus_equality: 
ballarin@19981
   168
  "[| x \<in> carrier G; y \<in> carrier G; y \<oplus> x = \<zero> |] ==> \<ominus> x = y" 
ballarin@19981
   169
  using group.inv_equality [OF a_group] 
ballarin@19981
   170
  by (auto simp add: a_inv_def) 
ballarin@19981
   171
 
ballarin@19981
   172
lemma (in abelian_monoid) minus_unique: 
ballarin@19981
   173
  "[| x \<in> carrier G; y \<in> carrier G; y' \<in> carrier G;
ballarin@19981
   174
      y \<oplus> x = \<zero>; x \<oplus> y' = \<zero> |] ==> y = y'" 
ballarin@19981
   175
  using monoid.inv_unique [OF a_monoid] 
ballarin@19981
   176
  by (simp add: a_inv_def) 
ballarin@19981
   177
ballarin@13936
   178
lemmas (in abelian_monoid) a_ac = a_assoc a_comm a_lcomm
ballarin@13936
   179
ballarin@13936
   180
subsection {* Sums over Finite Sets *}
ballarin@13936
   181
ballarin@13936
   182
text {*
ballarin@13936
   183
  This definition makes it easy to lift lemmas from @{term finprod}.
ballarin@13936
   184
*}
ballarin@13936
   185
ballarin@13936
   186
constdefs
ballarin@15095
   187
  finsum :: "[('b, 'm) ring_scheme, 'a => 'b, 'a set] => 'b"
ballarin@13936
   188
  "finsum G f A == finprod (| carrier = carrier G,
ballarin@13936
   189
     mult = add G, one = zero G |) f A"
ballarin@13936
   190
wenzelm@14651
   191
syntax
wenzelm@14651
   192
  "_finsum" :: "index => idt => 'a set => 'b => 'b"
wenzelm@14666
   193
      ("(3\<Oplus>__:_. _)" [1000, 0, 51, 10] 10)
wenzelm@14651
   194
syntax (xsymbols)
wenzelm@14651
   195
  "_finsum" :: "index => idt => 'a set => 'b => 'b"
wenzelm@14666
   196
      ("(3\<Oplus>__\<in>_. _)" [1000, 0, 51, 10] 10)
wenzelm@14651
   197
syntax (HTML output)
wenzelm@14651
   198
  "_finsum" :: "index => idt => 'a set => 'b => 'b"
wenzelm@14666
   199
      ("(3\<Oplus>__\<in>_. _)" [1000, 0, 51, 10] 10)
wenzelm@14651
   200
translations
ballarin@15095
   201
  "\<Oplus>\<index>i:A. b" == "finsum \<struct>\<index> (%i. b) A"
ballarin@15095
   202
  -- {* Beware of argument permutation! *}
wenzelm@14651
   203
ballarin@13936
   204
(*
ballarin@13936
   205
  lemmas (in abelian_monoid) finsum_empty [simp] =
ballarin@13936
   206
    comm_monoid.finprod_empty [OF a_comm_monoid, simplified]
ballarin@13936
   207
  is dangeous, because attributes (like simplified) are applied upon opening
ballarin@13936
   208
  the locale, simplified refers to the simpset at that time!!!
ballarin@13936
   209
ballarin@13936
   210
  lemmas (in abelian_monoid) finsum_empty [simp] =
ballarin@13936
   211
    abelian_monoid.finprod_empty [OF a_abelian_monoid, folded finsum_def,
ballarin@13936
   212
      simplified monoid_record_simps]
ballarin@15095
   213
  makes the locale slow, because proofs are repeated for every
ballarin@15095
   214
  "lemma (in abelian_monoid)" command.
ballarin@15095
   215
  When lemma is used time in UnivPoly.thy from beginning to UP_cring goes down
ballarin@15095
   216
  from 110 secs to 60 secs.
ballarin@13936
   217
*)
ballarin@13936
   218
ballarin@13936
   219
lemma (in abelian_monoid) finsum_empty [simp]:
ballarin@13936
   220
  "finsum G f {} = \<zero>"
ballarin@13936
   221
  by (rule comm_monoid.finprod_empty [OF a_comm_monoid,
ballarin@13936
   222
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   223
ballarin@13936
   224
lemma (in abelian_monoid) finsum_insert [simp]:
ballarin@13936
   225
  "[| finite F; a \<notin> F; f \<in> F -> carrier G; f a \<in> carrier G |]
ballarin@13936
   226
  ==> finsum G f (insert a F) = f a \<oplus> finsum G f F"
ballarin@13936
   227
  by (rule comm_monoid.finprod_insert [OF a_comm_monoid,
ballarin@13936
   228
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   229
ballarin@13936
   230
lemma (in abelian_monoid) finsum_zero [simp]:
ballarin@15095
   231
  "finite A ==> (\<Oplus>i\<in>A. \<zero>) = \<zero>"
ballarin@13936
   232
  by (rule comm_monoid.finprod_one [OF a_comm_monoid, folded finsum_def,
ballarin@13936
   233
    simplified monoid_record_simps])
ballarin@13936
   234
ballarin@13936
   235
lemma (in abelian_monoid) finsum_closed [simp]:
ballarin@13936
   236
  fixes A
ballarin@13936
   237
  assumes fin: "finite A" and f: "f \<in> A -> carrier G" 
ballarin@13936
   238
  shows "finsum G f A \<in> carrier G"
ballarin@13936
   239
  by (rule comm_monoid.finprod_closed [OF a_comm_monoid,
ballarin@13936
   240
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   241
ballarin@13936
   242
lemma (in abelian_monoid) finsum_Un_Int:
ballarin@13936
   243
  "[| finite A; finite B; g \<in> A -> carrier G; g \<in> B -> carrier G |] ==>
ballarin@13936
   244
     finsum G g (A Un B) \<oplus> finsum G g (A Int B) =
ballarin@13936
   245
     finsum G g A \<oplus> finsum G g B"
ballarin@13936
   246
  by (rule comm_monoid.finprod_Un_Int [OF a_comm_monoid,
ballarin@13936
   247
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   248
ballarin@13936
   249
lemma (in abelian_monoid) finsum_Un_disjoint:
ballarin@13936
   250
  "[| finite A; finite B; A Int B = {};
ballarin@13936
   251
      g \<in> A -> carrier G; g \<in> B -> carrier G |]
ballarin@13936
   252
   ==> finsum G g (A Un B) = finsum G g A \<oplus> finsum G g B"
ballarin@13936
   253
  by (rule comm_monoid.finprod_Un_disjoint [OF a_comm_monoid,
ballarin@13936
   254
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   255
ballarin@13936
   256
lemma (in abelian_monoid) finsum_addf:
ballarin@13936
   257
  "[| finite A; f \<in> A -> carrier G; g \<in> A -> carrier G |] ==>
ballarin@13936
   258
   finsum G (%x. f x \<oplus> g x) A = (finsum G f A \<oplus> finsum G g A)"
ballarin@13936
   259
  by (rule comm_monoid.finprod_multf [OF a_comm_monoid,
ballarin@13936
   260
    folded finsum_def, simplified monoid_record_simps])
ballarin@13936
   261
ballarin@13936
   262
lemma (in abelian_monoid) finsum_cong':
ballarin@13936
   263
  "[| A = B; g : B -> carrier G;
ballarin@13936
   264
      !!i. i : B ==> f i = g i |] ==> finsum G f A = finsum G g B"
ballarin@13936
   265
  by (rule comm_monoid.finprod_cong' [OF a_comm_monoid,
ballarin@13936
   266
    folded finsum_def, simplified monoid_record_simps]) auto
ballarin@13936
   267
ballarin@13936
   268
lemma (in abelian_monoid) finsum_0 [simp]:
ballarin@13936
   269
  "f : {0::nat} -> carrier G ==> finsum G f {..0} = f 0"
ballarin@13936
   270
  by (rule comm_monoid.finprod_0 [OF a_comm_monoid, folded finsum_def,
ballarin@13936
   271
    simplified monoid_record_simps])
ballarin@13936
   272
ballarin@13936
   273
lemma (in abelian_monoid) finsum_Suc [simp]:
ballarin@13936
   274
  "f : {..Suc n} -> carrier G ==>
ballarin@13936
   275
   finsum G f {..Suc n} = (f (Suc n) \<oplus> finsum G f {..n})"
ballarin@13936
   276
  by (rule comm_monoid.finprod_Suc [OF a_comm_monoid, folded finsum_def,
ballarin@13936
   277
    simplified monoid_record_simps])
ballarin@13936
   278
ballarin@13936
   279
lemma (in abelian_monoid) finsum_Suc2:
ballarin@13936
   280
  "f : {..Suc n} -> carrier G ==>
ballarin@13936
   281
   finsum G f {..Suc n} = (finsum G (%i. f (Suc i)) {..n} \<oplus> f 0)"
ballarin@13936
   282
  by (rule comm_monoid.finprod_Suc2 [OF a_comm_monoid, folded finsum_def,
ballarin@13936
   283
    simplified monoid_record_simps])
ballarin@13936
   284
ballarin@13936
   285
lemma (in abelian_monoid) finsum_add [simp]:
ballarin@13936
   286
  "[| f : {..n} -> carrier G; g : {..n} -> carrier G |] ==>
ballarin@13936
   287
     finsum G (%i. f i \<oplus> g i) {..n::nat} =
ballarin@13936
   288
     finsum G f {..n} \<oplus> finsum G g {..n}"
ballarin@13936
   289
  by (rule comm_monoid.finprod_mult [OF a_comm_monoid, folded finsum_def,
ballarin@13936
   290
    simplified monoid_record_simps])
ballarin@13936
   291
ballarin@13936
   292
lemma (in abelian_monoid) finsum_cong:
berghofe@16637
   293
  "[| A = B; f : B -> carrier G;
berghofe@16637
   294
      !!i. i : B =simp=> f i = g i |] ==> finsum G f A = finsum G g B"
ballarin@13936
   295
  by (rule comm_monoid.finprod_cong [OF a_comm_monoid, folded finsum_def,
berghofe@16637
   296
    simplified monoid_record_simps]) (auto simp add: simp_implies_def)
ballarin@13936
   297
ballarin@13936
   298
text {*Usually, if this rule causes a failed congruence proof error,
ballarin@13936
   299
   the reason is that the premise @{text "g \<in> B -> carrier G"} cannot be shown.
ballarin@13936
   300
   Adding @{thm [source] Pi_def} to the simpset is often useful. *}
ballarin@13936
   301
ballarin@13835
   302
section {* The Algebraic Hierarchy of Rings *}
ballarin@13835
   303
ballarin@13835
   304
subsection {* Basic Definitions *}
ballarin@13835
   305
ballarin@14399
   306
locale ring = abelian_group R + monoid R +
ballarin@13936
   307
  assumes l_distr: "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
ballarin@13835
   308
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
ballarin@14399
   309
    and r_distr: "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
ballarin@14399
   310
      ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
ballarin@14399
   311
ballarin@14399
   312
locale cring = ring + comm_monoid R
ballarin@13835
   313
ballarin@13864
   314
locale "domain" = cring +
ballarin@13864
   315
  assumes one_not_zero [simp]: "\<one> ~= \<zero>"
ballarin@13864
   316
    and integral: "[| a \<otimes> b = \<zero>; a \<in> carrier R; b \<in> carrier R |] ==>
ballarin@13864
   317
                  a = \<zero> | b = \<zero>"
ballarin@13864
   318
ballarin@14551
   319
locale field = "domain" +
ballarin@14551
   320
  assumes field_Units: "Units R = carrier R - {\<zero>}"
ballarin@14551
   321
ballarin@13864
   322
subsection {* Basic Facts of Rings *}
ballarin@13835
   323
ballarin@14399
   324
lemma ringI:
ballarin@19783
   325
  fixes R (structure)
ballarin@14399
   326
  assumes abelian_group: "abelian_group R"
ballarin@14399
   327
    and monoid: "monoid R"
ballarin@14399
   328
    and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
ballarin@15095
   329
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
ballarin@14399
   330
    and r_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
ballarin@14399
   331
      ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
ballarin@14399
   332
  shows "ring R"
ballarin@14399
   333
  by (auto intro: ring.intro
paulson@14963
   334
    abelian_group.axioms ring_axioms.intro prems)
ballarin@14399
   335
ballarin@14399
   336
lemma (in ring) is_abelian_group:
ballarin@14399
   337
  "abelian_group R"
ballarin@14399
   338
  by (auto intro!: abelian_groupI a_assoc a_comm l_neg)
ballarin@14399
   339
ballarin@14399
   340
lemma (in ring) is_monoid:
ballarin@14399
   341
  "monoid R"
ballarin@14399
   342
  by (auto intro!: monoidI m_assoc)
ballarin@14399
   343
ballarin@13936
   344
lemma cringI:
ballarin@19783
   345
  fixes R (structure)
ballarin@13936
   346
  assumes abelian_group: "abelian_group R"
ballarin@13936
   347
    and comm_monoid: "comm_monoid R"
ballarin@13936
   348
    and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
ballarin@15095
   349
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
ballarin@13936
   350
  shows "cring R"
ballarin@19931
   351
  proof (intro cring.intro ring.intro)
ballarin@14399
   352
    show "ring_axioms R"
ballarin@14399
   353
    -- {* Right-distributivity follows from left-distributivity and
ballarin@14399
   354
          commutativity. *}
ballarin@14399
   355
    proof (rule ring_axioms.intro)
ballarin@14399
   356
      fix x y z
ballarin@14399
   357
      assume R: "x \<in> carrier R" "y \<in> carrier R" "z \<in> carrier R"
ballarin@14399
   358
      note [simp]= comm_monoid.axioms [OF comm_monoid]
ballarin@14399
   359
        abelian_group.axioms [OF abelian_group]
ballarin@14399
   360
        abelian_monoid.a_closed
ballarin@14399
   361
        
ballarin@14399
   362
      from R have "z \<otimes> (x \<oplus> y) = (x \<oplus> y) \<otimes> z"
paulson@14963
   363
        by (simp add: comm_monoid.m_comm [OF comm_monoid.intro])
ballarin@14399
   364
      also from R have "... = x \<otimes> z \<oplus> y \<otimes> z" by (simp add: l_distr)
ballarin@14399
   365
      also from R have "... = z \<otimes> x \<oplus> z \<otimes> y"
paulson@14963
   366
        by (simp add: comm_monoid.m_comm [OF comm_monoid.intro])
ballarin@14399
   367
      finally show "z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y" .
ballarin@14399
   368
    qed
ballarin@14399
   369
  qed (auto intro: cring.intro
ballarin@14399
   370
      abelian_group.axioms comm_monoid.axioms ring_axioms.intro prems)
ballarin@13854
   371
ballarin@13936
   372
lemma (in cring) is_comm_monoid:
ballarin@13936
   373
  "comm_monoid R"
ballarin@13936
   374
  by (auto intro!: comm_monoidI m_assoc m_comm)
ballarin@13835
   375
ballarin@14551
   376
subsection {* Normaliser for Rings *}
ballarin@13835
   377
ballarin@13936
   378
lemma (in abelian_group) r_neg2:
ballarin@13936
   379
  "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<oplus> (\<ominus> x \<oplus> y) = y"
ballarin@13854
   380
proof -
ballarin@13936
   381
  assume G: "x \<in> carrier G" "y \<in> carrier G"
ballarin@13936
   382
  then have "(x \<oplus> \<ominus> x) \<oplus> y = y"
ballarin@13936
   383
    by (simp only: r_neg l_zero)
ballarin@13936
   384
  with G show ?thesis 
ballarin@13936
   385
    by (simp add: a_ac)
ballarin@13835
   386
qed
ballarin@13835
   387
ballarin@13936
   388
lemma (in abelian_group) r_neg1:
ballarin@13936
   389
  "[| x \<in> carrier G; y \<in> carrier G |] ==> \<ominus> x \<oplus> (x \<oplus> y) = y"
ballarin@13854
   390
proof -
ballarin@13936
   391
  assume G: "x \<in> carrier G" "y \<in> carrier G"
ballarin@13936
   392
  then have "(\<ominus> x \<oplus> x) \<oplus> y = y" 
ballarin@13936
   393
    by (simp only: l_neg l_zero)
ballarin@13854
   394
  with G show ?thesis by (simp add: a_ac)
ballarin@13835
   395
qed
ballarin@13835
   396
ballarin@13854
   397
text {* 
ballarin@13854
   398
  The following proofs are from Jacobson, Basic Algebra I, pp.~88--89
ballarin@13835
   399
*}
ballarin@13835
   400
ballarin@14399
   401
lemma (in ring) l_null [simp]:
ballarin@13854
   402
  "x \<in> carrier R ==> \<zero> \<otimes> x = \<zero>"
ballarin@13854
   403
proof -
ballarin@13854
   404
  assume R: "x \<in> carrier R"
ballarin@13854
   405
  then have "\<zero> \<otimes> x \<oplus> \<zero> \<otimes> x = (\<zero> \<oplus> \<zero>) \<otimes> x"
ballarin@13854
   406
    by (simp add: l_distr del: l_zero r_zero)
ballarin@13854
   407
  also from R have "... = \<zero> \<otimes> x \<oplus> \<zero>" by simp
ballarin@13854
   408
  finally have "\<zero> \<otimes> x \<oplus> \<zero> \<otimes> x = \<zero> \<otimes> x \<oplus> \<zero>" .
ballarin@13854
   409
  with R show ?thesis by (simp del: r_zero)
ballarin@13854
   410
qed
ballarin@13835
   411
ballarin@14399
   412
lemma (in ring) r_null [simp]:
ballarin@13854
   413
  "x \<in> carrier R ==> x \<otimes> \<zero> = \<zero>"
ballarin@13854
   414
proof -
ballarin@13854
   415
  assume R: "x \<in> carrier R"
ballarin@14399
   416
  then have "x \<otimes> \<zero> \<oplus> x \<otimes> \<zero> = x \<otimes> (\<zero> \<oplus> \<zero>)"
ballarin@14399
   417
    by (simp add: r_distr del: l_zero r_zero)
ballarin@14399
   418
  also from R have "... = x \<otimes> \<zero> \<oplus> \<zero>" by simp
ballarin@14399
   419
  finally have "x \<otimes> \<zero> \<oplus> x \<otimes> \<zero> = x \<otimes> \<zero> \<oplus> \<zero>" .
ballarin@14399
   420
  with R show ?thesis by (simp del: r_zero)
ballarin@13854
   421
qed
ballarin@13835
   422
ballarin@14399
   423
lemma (in ring) l_minus:
ballarin@13854
   424
  "[| x \<in> carrier R; y \<in> carrier R |] ==> \<ominus> x \<otimes> y = \<ominus> (x \<otimes> y)"
ballarin@13854
   425
proof -
ballarin@13854
   426
  assume R: "x \<in> carrier R" "y \<in> carrier R"
ballarin@13854
   427
  then have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y = (\<ominus> x \<oplus> x) \<otimes> y" by (simp add: l_distr)
ballarin@13854
   428
  also from R have "... = \<zero>" by (simp add: l_neg l_null)
ballarin@13854
   429
  finally have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y = \<zero>" .
ballarin@13854
   430
  with R have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y \<oplus> \<ominus> (x \<otimes> y) = \<zero> \<oplus> \<ominus> (x \<otimes> y)" by simp
ballarin@13854
   431
  with R show ?thesis by (simp add: a_assoc r_neg )
ballarin@13835
   432
qed
ballarin@13835
   433
ballarin@14399
   434
lemma (in ring) r_minus:
ballarin@13854
   435
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<otimes> \<ominus> y = \<ominus> (x \<otimes> y)"
ballarin@13854
   436
proof -
ballarin@13854
   437
  assume R: "x \<in> carrier R" "y \<in> carrier R"
ballarin@14399
   438
  then have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y = x \<otimes> (\<ominus> y \<oplus> y)" by (simp add: r_distr)
ballarin@14399
   439
  also from R have "... = \<zero>" by (simp add: l_neg r_null)
ballarin@14399
   440
  finally have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y = \<zero>" .
ballarin@14399
   441
  with R have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y \<oplus> \<ominus> (x \<otimes> y) = \<zero> \<oplus> \<ominus> (x \<otimes> y)" by simp
ballarin@14399
   442
  with R show ?thesis by (simp add: a_assoc r_neg )
ballarin@13835
   443
qed
ballarin@13835
   444
ballarin@14399
   445
lemma (in ring) minus_eq:
ballarin@13936
   446
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<ominus> y = x \<oplus> \<ominus> y"
haftmann@19233
   447
  by (simp only: a_minus_def)
ballarin@13936
   448
ballarin@20168
   449
text {* Setup algebra method:
ballarin@20168
   450
  compute distributive normal form in locale contexts *}
ballarin@20168
   451
ballarin@20168
   452
use "ringsimp.ML"
ballarin@20168
   453
ballarin@20168
   454
setup Algebra.setup
ballarin@20168
   455
ballarin@20168
   456
lemmas (in ring) ring_simprules
ballarin@20168
   457
  [algebra ring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
ballarin@14399
   458
  a_closed zero_closed a_inv_closed minus_closed m_closed one_closed
ballarin@14399
   459
  a_assoc l_zero l_neg a_comm m_assoc l_one l_distr minus_eq
ballarin@14399
   460
  r_zero r_neg r_neg2 r_neg1 minus_add minus_minus minus_zero
ballarin@14399
   461
  a_lcomm r_distr l_null r_null l_minus r_minus
ballarin@14399
   462
ballarin@20168
   463
lemmas (in cring)
ballarin@20168
   464
  [algebra del: ring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
ballarin@20168
   465
  _
ballarin@20168
   466
ballarin@20168
   467
lemmas (in cring) cring_simprules
ballarin@20168
   468
  [algebra add: cring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
ballarin@13854
   469
  a_closed zero_closed a_inv_closed minus_closed m_closed one_closed
ballarin@13936
   470
  a_assoc l_zero l_neg a_comm m_assoc l_one l_distr m_comm minus_eq
ballarin@13854
   471
  r_zero r_neg r_neg2 r_neg1 minus_add minus_minus minus_zero
ballarin@13854
   472
  a_lcomm m_lcomm r_distr l_null r_null l_minus r_minus
ballarin@13854
   473
ballarin@13936
   474
ballarin@13936
   475
lemma (in cring) nat_pow_zero:
ballarin@13936
   476
  "(n::nat) ~= 0 ==> \<zero> (^) n = \<zero>"
ballarin@13936
   477
  by (induct n) simp_all
ballarin@13854
   478
ballarin@13864
   479
text {* Two examples for use of method algebra *}
ballarin@13864
   480
ballarin@13854
   481
lemma
ballarin@14399
   482
  includes ring R + cring S
ballarin@13854
   483
  shows "[| a \<in> carrier R; b \<in> carrier R; c \<in> carrier S; d \<in> carrier S |] ==> 
ballarin@15095
   484
  a \<oplus> \<ominus> (a \<oplus> \<ominus> b) = b & c \<otimes>\<^bsub>S\<^esub> d = d \<otimes>\<^bsub>S\<^esub> c"
ballarin@13854
   485
  by algebra
ballarin@13854
   486
ballarin@13854
   487
lemma
ballarin@13854
   488
  includes cring
ballarin@13854
   489
  shows "[| a \<in> carrier R; b \<in> carrier R |] ==> a \<ominus> (a \<ominus> b) = b"
ballarin@13854
   490
  by algebra
ballarin@13835
   491
ballarin@13864
   492
subsection {* Sums over Finite Sets *}
ballarin@13864
   493
ballarin@13864
   494
lemma (in cring) finsum_ldistr:
ballarin@13864
   495
  "[| finite A; a \<in> carrier R; f \<in> A -> carrier R |] ==>
ballarin@13864
   496
   finsum R f A \<otimes> a = finsum R (%i. f i \<otimes> a) A"
ballarin@13864
   497
proof (induct set: Finites)
ballarin@13864
   498
  case empty then show ?case by simp
ballarin@13864
   499
next
nipkow@15328
   500
  case (insert x F) then show ?case by (simp add: Pi_def l_distr)
ballarin@13864
   501
qed
ballarin@13864
   502
ballarin@13864
   503
lemma (in cring) finsum_rdistr:
ballarin@13864
   504
  "[| finite A; a \<in> carrier R; f \<in> A -> carrier R |] ==>
ballarin@13864
   505
   a \<otimes> finsum R f A = finsum R (%i. a \<otimes> f i) A"
ballarin@13864
   506
proof (induct set: Finites)
ballarin@13864
   507
  case empty then show ?case by simp
ballarin@13864
   508
next
nipkow@15328
   509
  case (insert x F) then show ?case by (simp add: Pi_def r_distr)
ballarin@13864
   510
qed
ballarin@13864
   511
ballarin@13864
   512
subsection {* Facts of Integral Domains *}
ballarin@13864
   513
ballarin@13864
   514
lemma (in "domain") zero_not_one [simp]:
ballarin@13864
   515
  "\<zero> ~= \<one>"
ballarin@13864
   516
  by (rule not_sym) simp
ballarin@13864
   517
ballarin@13864
   518
lemma (in "domain") integral_iff: (* not by default a simp rule! *)
ballarin@13864
   519
  "[| a \<in> carrier R; b \<in> carrier R |] ==> (a \<otimes> b = \<zero>) = (a = \<zero> | b = \<zero>)"
ballarin@13864
   520
proof
ballarin@13864
   521
  assume "a \<in> carrier R" "b \<in> carrier R" "a \<otimes> b = \<zero>"
ballarin@13864
   522
  then show "a = \<zero> | b = \<zero>" by (simp add: integral)
ballarin@13864
   523
next
ballarin@13864
   524
  assume "a \<in> carrier R" "b \<in> carrier R" "a = \<zero> | b = \<zero>"
ballarin@13864
   525
  then show "a \<otimes> b = \<zero>" by auto
ballarin@13864
   526
qed
ballarin@13864
   527
ballarin@13864
   528
lemma (in "domain") m_lcancel:
ballarin@13864
   529
  assumes prem: "a ~= \<zero>"
ballarin@13864
   530
    and R: "a \<in> carrier R" "b \<in> carrier R" "c \<in> carrier R"
ballarin@13864
   531
  shows "(a \<otimes> b = a \<otimes> c) = (b = c)"
ballarin@13864
   532
proof
ballarin@13864
   533
  assume eq: "a \<otimes> b = a \<otimes> c"
ballarin@13864
   534
  with R have "a \<otimes> (b \<ominus> c) = \<zero>" by algebra
ballarin@13864
   535
  with R have "a = \<zero> | (b \<ominus> c) = \<zero>" by (simp add: integral_iff)
ballarin@13864
   536
  with prem and R have "b \<ominus> c = \<zero>" by auto 
ballarin@13864
   537
  with R have "b = b \<ominus> (b \<ominus> c)" by algebra 
ballarin@13864
   538
  also from R have "b \<ominus> (b \<ominus> c) = c" by algebra
ballarin@13864
   539
  finally show "b = c" .
ballarin@13864
   540
next
ballarin@13864
   541
  assume "b = c" then show "a \<otimes> b = a \<otimes> c" by simp
ballarin@13864
   542
qed
ballarin@13864
   543
ballarin@13864
   544
lemma (in "domain") m_rcancel:
ballarin@13864
   545
  assumes prem: "a ~= \<zero>"
ballarin@13864
   546
    and R: "a \<in> carrier R" "b \<in> carrier R" "c \<in> carrier R"
ballarin@13864
   547
  shows conc: "(b \<otimes> a = c \<otimes> a) = (b = c)"
ballarin@13864
   548
proof -
ballarin@13864
   549
  from prem and R have "(a \<otimes> b = a \<otimes> c) = (b = c)" by (rule m_lcancel)
ballarin@13864
   550
  with R show ?thesis by algebra
ballarin@13864
   551
qed
ballarin@13864
   552
ballarin@13936
   553
subsection {* Morphisms *}
ballarin@13936
   554
ballarin@15095
   555
constdefs (structure R S)
ballarin@13936
   556
  ring_hom :: "[('a, 'm) ring_scheme, ('b, 'n) ring_scheme] => ('a => 'b) set"
ballarin@13936
   557
  "ring_hom R S == {h. h \<in> carrier R -> carrier S &
ballarin@13936
   558
      (ALL x y. x \<in> carrier R & y \<in> carrier R -->
ballarin@15095
   559
        h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y & h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y) &
ballarin@15095
   560
      h \<one> = \<one>\<^bsub>S\<^esub>}"
ballarin@13936
   561
ballarin@13936
   562
lemma ring_hom_memI:
ballarin@19783
   563
  fixes R (structure) and S (structure)
ballarin@13936
   564
  assumes hom_closed: "!!x. x \<in> carrier R ==> h x \<in> carrier S"
ballarin@13936
   565
    and hom_mult: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
ballarin@15095
   566
      h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
ballarin@13936
   567
    and hom_add: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
ballarin@15095
   568
      h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
ballarin@15095
   569
    and hom_one: "h \<one> = \<one>\<^bsub>S\<^esub>"
ballarin@13936
   570
  shows "h \<in> ring_hom R S"
ballarin@13936
   571
  by (auto simp add: ring_hom_def prems Pi_def)
ballarin@13936
   572
ballarin@13936
   573
lemma ring_hom_closed:
ballarin@13936
   574
  "[| h \<in> ring_hom R S; x \<in> carrier R |] ==> h x \<in> carrier S"
ballarin@13936
   575
  by (auto simp add: ring_hom_def funcset_mem)
ballarin@13936
   576
ballarin@13936
   577
lemma ring_hom_mult:
ballarin@19783
   578
  fixes R (structure) and S (structure)
ballarin@15095
   579
  shows
ballarin@15095
   580
    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
ballarin@15095
   581
    h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
ballarin@15095
   582
    by (simp add: ring_hom_def)
ballarin@13936
   583
ballarin@13936
   584
lemma ring_hom_add:
ballarin@19783
   585
  fixes R (structure) and S (structure)
ballarin@15095
   586
  shows
ballarin@15095
   587
    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
ballarin@15095
   588
    h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
ballarin@15095
   589
    by (simp add: ring_hom_def)
ballarin@13936
   590
ballarin@13936
   591
lemma ring_hom_one:
ballarin@19783
   592
  fixes R (structure) and S (structure)
ballarin@15095
   593
  shows "h \<in> ring_hom R S ==> h \<one> = \<one>\<^bsub>S\<^esub>"
ballarin@13936
   594
  by (simp add: ring_hom_def)
ballarin@13936
   595
ballarin@19783
   596
locale ring_hom_cring = cring R + cring S +
ballarin@19783
   597
  fixes h
ballarin@13936
   598
  assumes homh [simp, intro]: "h \<in> ring_hom R S"
ballarin@13936
   599
  notes hom_closed [simp, intro] = ring_hom_closed [OF homh]
ballarin@13936
   600
    and hom_mult [simp] = ring_hom_mult [OF homh]
ballarin@13936
   601
    and hom_add [simp] = ring_hom_add [OF homh]
ballarin@13936
   602
    and hom_one [simp] = ring_hom_one [OF homh]
ballarin@13936
   603
ballarin@13936
   604
lemma (in ring_hom_cring) hom_zero [simp]:
ballarin@15095
   605
  "h \<zero> = \<zero>\<^bsub>S\<^esub>"
ballarin@13936
   606
proof -
ballarin@15095
   607
  have "h \<zero> \<oplus>\<^bsub>S\<^esub> h \<zero> = h \<zero> \<oplus>\<^bsub>S\<^esub> \<zero>\<^bsub>S\<^esub>"
ballarin@13936
   608
    by (simp add: hom_add [symmetric] del: hom_add)
ballarin@13936
   609
  then show ?thesis by (simp del: S.r_zero)
ballarin@13936
   610
qed
ballarin@13936
   611
ballarin@13936
   612
lemma (in ring_hom_cring) hom_a_inv [simp]:
ballarin@15095
   613
  "x \<in> carrier R ==> h (\<ominus> x) = \<ominus>\<^bsub>S\<^esub> h x"
ballarin@13936
   614
proof -
ballarin@13936
   615
  assume R: "x \<in> carrier R"
ballarin@15095
   616
  then have "h x \<oplus>\<^bsub>S\<^esub> h (\<ominus> x) = h x \<oplus>\<^bsub>S\<^esub> (\<ominus>\<^bsub>S\<^esub> h x)"
ballarin@13936
   617
    by (simp add: hom_add [symmetric] R.r_neg S.r_neg del: hom_add)
ballarin@13936
   618
  with R show ?thesis by simp
ballarin@13936
   619
qed
ballarin@13936
   620
ballarin@13936
   621
lemma (in ring_hom_cring) hom_finsum [simp]:
ballarin@13936
   622
  "[| finite A; f \<in> A -> carrier R |] ==>
ballarin@13936
   623
  h (finsum R f A) = finsum S (h o f) A"
ballarin@13936
   624
proof (induct set: Finites)
ballarin@13936
   625
  case empty then show ?case by simp
ballarin@13936
   626
next
ballarin@13936
   627
  case insert then show ?case by (simp add: Pi_def)
ballarin@13936
   628
qed
ballarin@13936
   629
ballarin@13936
   630
lemma (in ring_hom_cring) hom_finprod:
ballarin@13936
   631
  "[| finite A; f \<in> A -> carrier R |] ==>
ballarin@13936
   632
  h (finprod R f A) = finprod S (h o f) A"
ballarin@13936
   633
proof (induct set: Finites)
ballarin@13936
   634
  case empty then show ?case by simp
ballarin@13936
   635
next
ballarin@13936
   636
  case insert then show ?case by (simp add: Pi_def)
ballarin@13936
   637
qed
ballarin@13936
   638
ballarin@13936
   639
declare ring_hom_cring.hom_finprod [simp]
ballarin@13936
   640
ballarin@13936
   641
lemma id_ring_hom [simp]:
ballarin@13936
   642
  "id \<in> ring_hom R R"
ballarin@13936
   643
  by (auto intro!: ring_hom_memI)
ballarin@13936
   644
ballarin@13835
   645
end