src/HOL/Algebra/Ring.thy
author wenzelm
Thu, 15 Feb 2018 12:11:00 +0100
changeset 67613 ce654b0e6d69
parent 67398 5eb932e604a2
child 68399 0b71d08528f0
permissions -rw-r--r--
more symbols;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41959
b460124855b8 tuned headers;
wenzelm
parents: 41433
diff changeset
     1
(*  Title:      HOL/Algebra/Ring.thy
35849
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
     2
    Author:     Clemens Ballarin, started 9 December 1996
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
     3
    Copyright:  Clemens Ballarin
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     4
*)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     5
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 27933
diff changeset
     6
theory Ring
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 27933
diff changeset
     7
imports FiniteProduct
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
     8
begin
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
     9
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
    10
section \<open>The Algebraic Hierarchy of Rings\<close>
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27714
diff changeset
    11
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
    12
subsection \<open>Abelian Groups\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    13
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    14
record 'a ring = "'a monoid" +
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    15
  zero :: 'a ("\<zero>\<index>")
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    16
  add :: "['a, 'a] => 'a" (infixl "\<oplus>\<index>" 65)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    17
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
    18
text \<open>Derived operations.\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    19
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
    20
definition
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    21
  a_inv :: "[('a, 'm) ring_scheme, 'a ] => 'a" ("\<ominus>\<index> _" [81] 80)
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    22
  where "a_inv R = m_inv \<lparr>carrier = carrier R, mult = add R, one = zero R\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    23
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
    24
definition
67398
5eb932e604a2 Manual updates towards conversion of "op" syntax
nipkow
parents: 67341
diff changeset
    25
  a_minus :: "[('a, 'm) ring_scheme, 'a, 'a] => 'a" ("(_ \<ominus>\<index> _)" [65,66] 65)
35848
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
    26
  where "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<ominus>\<^bsub>R\<^esub> y = x \<oplus>\<^bsub>R\<^esub> (\<ominus>\<^bsub>R\<^esub> y)"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    27
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    28
locale abelian_monoid =
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    29
  fixes G (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    30
  assumes a_comm_monoid:
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    31
     "comm_monoid \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    32
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    33
definition
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    34
  finsum :: "[('b, 'm) ring_scheme, 'a => 'b, 'a set] => 'b" where
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    35
  "finsum G = finprod \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    36
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    37
syntax
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    38
  "_finsum" :: "index => idt => 'a set => 'b => 'b"
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    39
      ("(3\<Oplus>__\<in>_. _)" [1000, 0, 51, 10] 10)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    40
translations
62105
wenzelm
parents: 61605
diff changeset
    41
  "\<Oplus>\<^bsub>G\<^esub>i\<in>A. b" \<rightleftharpoons> "CONST finsum G (%i. b) A"
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 62105
diff changeset
    42
  \<comment> \<open>Beware of argument permutation!\<close>
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    43
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    44
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    45
locale abelian_group = abelian_monoid +
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    46
  assumes a_comm_group:
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    47
     "comm_group \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    48
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    49
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
    50
subsection \<open>Basic Properties\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    51
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    52
lemma abelian_monoidI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    53
  fixes R (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    54
  assumes a_closed:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    55
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    56
    and zero_closed: "\<zero> \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    57
    and a_assoc:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    58
      "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    59
      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    60
    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    61
    and a_comm:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    62
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    63
  shows "abelian_monoid R"
27714
27b4d7c01f8b Tuned (for the sake of a meaningless log entry).
ballarin
parents: 27699
diff changeset
    64
  by (auto intro!: abelian_monoid.intro comm_monoidI intro: assms)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    65
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    66
lemma abelian_groupI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    67
  fixes R (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    68
  assumes a_closed:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    69
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    70
    and zero_closed: "zero R \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    71
    and a_assoc:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    72
      "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    73
      (x \<oplus> y) \<oplus> z = x \<oplus> (y \<oplus> z)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    74
    and a_comm:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    75
      "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> y = y \<oplus> x"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    76
    and l_zero: "!!x. x \<in> carrier R ==> \<zero> \<oplus> x = x"
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 67398
diff changeset
    77
    and l_inv_ex: "\<And>x. x \<in> carrier R \<Longrightarrow> \<exists>y \<in> carrier R. y \<oplus> x = \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    78
  shows "abelian_group R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    79
  by (auto intro!: abelian_group.intro abelian_monoidI
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    80
      abelian_group_axioms.intro comm_monoidI comm_groupI
27714
27b4d7c01f8b Tuned (for the sake of a meaningless log entry).
ballarin
parents: 27699
diff changeset
    81
    intro: assms)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    82
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    83
lemma (in abelian_monoid) a_monoid:
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    84
  "monoid \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    85
by (rule comm_monoid.axioms, rule a_comm_monoid) 
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    86
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    87
lemma (in abelian_group) a_group:
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    88
  "group \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    89
  by (simp add: group_def a_monoid)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    90
    (simp add: comm_group.axioms group.axioms a_comm_group)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    91
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    92
lemmas monoid_record_simps = partial_object.simps monoid.simps
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    93
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
    94
text \<open>Transfer facts from multiplicative structures via interpretation.\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
    95
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
    96
sublocale abelian_monoid <
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61566
diff changeset
    97
  add: monoid "\<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
61566
c3d6e570ccef Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents: 61565
diff changeset
    98
  rewrites "carrier \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = carrier G"
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
    99
    and "mult \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = add G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   100
    and "one \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = zero G"
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   101
  by (rule a_monoid) auto
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   102
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   103
context abelian_monoid begin
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   104
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   105
lemmas a_closed = add.m_closed 
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   106
lemmas zero_closed = add.one_closed
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   107
lemmas a_assoc = add.m_assoc
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   108
lemmas l_zero = add.l_one
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   109
lemmas r_zero = add.r_one
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   110
lemmas minus_unique = add.inv_unique
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   111
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   112
end
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   113
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   114
sublocale abelian_monoid <
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61566
diff changeset
   115
  add: comm_monoid "\<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
61566
c3d6e570ccef Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents: 61565
diff changeset
   116
  rewrites "carrier \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = carrier G"
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   117
    and "mult \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = add G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   118
    and "one \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = zero G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   119
    and "finprod \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = finsum G"
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   120
  by (rule a_comm_monoid) (auto simp: finsum_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   121
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   122
context abelian_monoid begin
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   123
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   124
lemmas a_comm = add.m_comm
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   125
lemmas a_lcomm = add.m_lcomm
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   126
lemmas a_ac = a_assoc a_comm a_lcomm
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   127
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   128
lemmas finsum_empty = add.finprod_empty
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   129
lemmas finsum_insert = add.finprod_insert
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   130
lemmas finsum_zero = add.finprod_one
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   131
lemmas finsum_closed = add.finprod_closed
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   132
lemmas finsum_Un_Int = add.finprod_Un_Int
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   133
lemmas finsum_Un_disjoint = add.finprod_Un_disjoint
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   134
lemmas finsum_addf = add.finprod_multf
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   135
lemmas finsum_cong' = add.finprod_cong'
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   136
lemmas finsum_0 = add.finprod_0
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   137
lemmas finsum_Suc = add.finprod_Suc
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   138
lemmas finsum_Suc2 = add.finprod_Suc2
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   139
lemmas finsum_add = add.finprod_mult
60112
3eab4acaa035 finprod takes 1 in case of infinite sets => remove several "finite A" assumptions
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 59851
diff changeset
   140
lemmas finsum_infinite = add.finprod_infinite
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   141
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   142
lemmas finsum_cong = add.finprod_cong
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   143
text \<open>Usually, if this rule causes a failed congruence proof error,
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 62105
diff changeset
   144
   the reason is that the premise \<open>g \<in> B \<rightarrow> carrier G\<close> cannot be shown.
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   145
   Adding @{thm [source] Pi_def} to the simpset is often useful.\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   146
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   147
lemmas finsum_reindex = add.finprod_reindex
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   148
67341
df79ef3b3a41 Renamed (^) to [^] in preparation of the move from "op X" to (X)
nipkow
parents: 67091
diff changeset
   149
(* The following would be wrong.  Needed is the equivalent of [^] for addition,
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   150
  or indeed the canonical embedding from Nat into the monoid.
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   151
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   152
lemma finsum_const:
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   153
  assumes fin [simp]: "finite A"
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   154
      and a [simp]: "a : carrier G"
67341
df79ef3b3a41 Renamed (^) to [^] in preparation of the move from "op X" to (X)
nipkow
parents: 67091
diff changeset
   155
    shows "finsum G (%x. a) A = a [^] card A"
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   156
  using fin apply induct
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   157
  apply force
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   158
  apply (subst finsum_insert)
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   159
  apply auto
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   160
  apply (force simp add: Pi_def)
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   161
  apply (subst m_comm)
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   162
  apply auto
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   163
done
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   164
*)
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   165
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   166
lemmas finsum_singleton = add.finprod_singleton
27933
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   167
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   168
end
4b867f6a65d3 Theorem on polynomial division and lemmas.
ballarin
parents: 27717
diff changeset
   169
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   170
sublocale abelian_group <
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61566
diff changeset
   171
  add: group "\<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
61566
c3d6e570ccef Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents: 61565
diff changeset
   172
  rewrites "carrier \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = carrier G"
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   173
    and "mult \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = add G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   174
    and "one \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = zero G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   175
    and "m_inv \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = a_inv G"
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   176
  by (rule a_group) (auto simp: m_inv_def a_inv_def)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   177
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   178
context abelian_group
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   179
begin
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   180
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   181
lemmas a_inv_closed = add.inv_closed
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   182
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   183
lemma minus_closed [intro, simp]:
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   184
  "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<ominus> y \<in> carrier G"
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   185
  by (simp add: a_minus_def)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   186
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   187
lemmas a_l_cancel = add.l_cancel
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   188
lemmas a_r_cancel = add.r_cancel
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   189
lemmas l_neg = add.l_inv [simp del]
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   190
lemmas r_neg = add.r_inv [simp del]
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   191
lemmas minus_zero = add.inv_one
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   192
lemmas minus_minus = add.inv_inv
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   193
lemmas a_inv_inj = add.inv_inj
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   194
lemmas minus_equality = add.inv_equality
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   195
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   196
end
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   197
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   198
sublocale abelian_group <
61605
1bf7b186542e qualifier is mandatory by default;
wenzelm
parents: 61566
diff changeset
   199
  add: comm_group "\<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
61566
c3d6e570ccef Keyword 'rewrites' identifies rewrite morphisms.
ballarin
parents: 61565
diff changeset
   200
  rewrites "carrier \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = carrier G"
55926
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   201
    and "mult \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = add G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   202
    and "one \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = zero G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   203
    and "m_inv \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = a_inv G"
3ef14caf5637 more symbols;
wenzelm
parents: 48891
diff changeset
   204
    and "finprod \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr> = finsum G"
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   205
  by (rule a_comm_group) (auto simp: m_inv_def a_inv_def finsum_def)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   206
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   207
lemmas (in abelian_group) minus_add = add.inv_mult
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   208
 
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 62105
diff changeset
   209
text \<open>Derive an \<open>abelian_group\<close> from a \<open>comm_group\<close>\<close>
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   210
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   211
lemma comm_group_abelian_groupI:
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   212
  fixes G (structure)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   213
  assumes cg: "comm_group \<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   214
  shows "abelian_group G"
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   215
proof -
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   216
  interpret comm_group "\<lparr>carrier = carrier G, mult = add G, one = zero G\<rparr>"
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   217
    by (rule cg)
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   218
  show "abelian_group G" ..
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   219
qed
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   220
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   221
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   222
subsection \<open>Rings: Basic Definitions\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   223
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   224
locale semiring = abelian_monoid R + monoid R for R (structure) +
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   225
  assumes l_distr: "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   226
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   227
    and r_distr: "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   228
      ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   229
    and l_null[simp]: "x \<in> carrier R ==> \<zero> \<otimes> x = \<zero>"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   230
    and r_null[simp]: "x \<in> carrier R ==> x \<otimes> \<zero> = \<zero>"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   231
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   232
locale ring = abelian_group R + monoid R for R (structure) +
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   233
  assumes "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   234
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   235
    and "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   236
      ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   237
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   238
locale cring = ring + comm_monoid R
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   239
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   240
locale "domain" = cring +
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   241
  assumes one_not_zero [simp]: "\<one> \<noteq> \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   242
    and integral: "[| a \<otimes> b = \<zero>; a \<in> carrier R; b \<in> carrier R |] ==>
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   243
                  a = \<zero> \<or> b = \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   244
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   245
locale field = "domain" +
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   246
  assumes field_Units: "Units R = carrier R - {\<zero>}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   247
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   248
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   249
subsection \<open>Rings\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   250
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   251
lemma ringI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   252
  fixes R (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   253
  assumes abelian_group: "abelian_group R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   254
    and monoid: "monoid R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   255
    and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   256
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   257
    and r_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   258
      ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   259
  shows "ring R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   260
  by (auto intro: ring.intro
27714
27b4d7c01f8b Tuned (for the sake of a meaningless log entry).
ballarin
parents: 27699
diff changeset
   261
    abelian_group.axioms ring_axioms.intro assms)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   262
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   263
context ring begin
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   264
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   265
lemma is_abelian_group: "abelian_group R" ..
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   266
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   267
lemma is_monoid: "monoid R"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   268
  by (auto intro!: monoidI m_assoc)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   269
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   270
lemma is_ring: "ring R"
26202
51f8a696cd8d explicit referencing of background facts;
wenzelm
parents: 23957
diff changeset
   271
  by (rule ring_axioms)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   272
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   273
end
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   274
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   275
lemmas ring_record_simps = monoid_record_simps ring.simps
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   276
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   277
lemma cringI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   278
  fixes R (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   279
  assumes abelian_group: "abelian_group R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   280
    and comm_monoid: "comm_monoid R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   281
    and l_distr: "!!x y z. [| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   282
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   283
  shows "cring R"
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   284
proof (intro cring.intro ring.intro)
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   285
  show "ring_axioms R"
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 62105
diff changeset
   286
    \<comment> \<open>Right-distributivity follows from left-distributivity and
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   287
          commutativity.\<close>
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   288
  proof (rule ring_axioms.intro)
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   289
    fix x y z
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   290
    assume R: "x \<in> carrier R" "y \<in> carrier R" "z \<in> carrier R"
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   291
    note [simp] = comm_monoid.axioms [OF comm_monoid]
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   292
      abelian_group.axioms [OF abelian_group]
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   293
      abelian_monoid.a_closed
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   294
        
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   295
    from R have "z \<otimes> (x \<oplus> y) = (x \<oplus> y) \<otimes> z"
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   296
      by (simp add: comm_monoid.m_comm [OF comm_monoid.intro])
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   297
    also from R have "... = x \<otimes> z \<oplus> y \<otimes> z" by (simp add: l_distr)
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   298
    also from R have "... = z \<otimes> x \<oplus> z \<otimes> y"
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   299
      by (simp add: comm_monoid.m_comm [OF comm_monoid.intro])
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   300
    finally show "z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y" .
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   301
  qed (rule l_distr)
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   302
qed (auto intro: cring.intro
27714
27b4d7c01f8b Tuned (for the sake of a meaningless log entry).
ballarin
parents: 27699
diff changeset
   303
  abelian_group.axioms comm_monoid.axioms ring_axioms.intro assms)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   304
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   305
(*
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   306
lemma (in cring) is_comm_monoid:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   307
  "comm_monoid R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   308
  by (auto intro!: comm_monoidI m_assoc m_comm)
27699
489e3f33af0e New theorems on summation.
ballarin
parents: 27611
diff changeset
   309
*)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   310
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   311
lemma (in cring) is_cring:
26202
51f8a696cd8d explicit referencing of background facts;
wenzelm
parents: 23957
diff changeset
   312
  "cring R" by (rule cring_axioms)
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   313
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   314
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   315
subsubsection \<open>Normaliser for Rings\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   316
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   317
lemma (in abelian_group) r_neg2:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   318
  "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<oplus> (\<ominus> x \<oplus> y) = y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   319
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   320
  assume G: "x \<in> carrier G" "y \<in> carrier G"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   321
  then have "(x \<oplus> \<ominus> x) \<oplus> y = y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   322
    by (simp only: r_neg l_zero)
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   323
  with G show ?thesis
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   324
    by (simp add: a_ac)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   325
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   326
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   327
lemma (in abelian_group) r_neg1:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   328
  "[| x \<in> carrier G; y \<in> carrier G |] ==> \<ominus> x \<oplus> (x \<oplus> y) = y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   329
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   330
  assume G: "x \<in> carrier G" "y \<in> carrier G"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   331
  then have "(\<ominus> x \<oplus> x) \<oplus> y = y" 
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   332
    by (simp only: l_neg l_zero)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   333
  with G show ?thesis by (simp add: a_ac)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   334
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   335
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   336
context ring begin
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   337
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   338
text \<open>
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   339
  The following proofs are from Jacobson, Basic Algebra I, pp.~88--89.
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   340
\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   341
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   342
sublocale semiring
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   343
proof -
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   344
  note [simp] = ring_axioms[unfolded ring_def ring_axioms_def]
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   345
  show "semiring R"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   346
  proof (unfold_locales)
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   347
    fix x
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   348
    assume R: "x \<in> carrier R"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   349
    then have "\<zero> \<otimes> x \<oplus> \<zero> \<otimes> x = (\<zero> \<oplus> \<zero>) \<otimes> x"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   350
      by (simp del: l_zero r_zero)
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   351
    also from R have "... = \<zero> \<otimes> x \<oplus> \<zero>" by simp
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   352
    finally have "\<zero> \<otimes> x \<oplus> \<zero> \<otimes> x = \<zero> \<otimes> x \<oplus> \<zero>" .
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   353
    with R show "\<zero> \<otimes> x = \<zero>" by (simp del: r_zero)
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   354
    from R have "x \<otimes> \<zero> \<oplus> x \<otimes> \<zero> = x \<otimes> (\<zero> \<oplus> \<zero>)"
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   355
      by (simp del: l_zero r_zero)
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   356
    also from R have "... = x \<otimes> \<zero> \<oplus> \<zero>" by simp
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   357
    finally have "x \<otimes> \<zero> \<oplus> x \<otimes> \<zero> = x \<otimes> \<zero> \<oplus> \<zero>" .
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   358
    with R show "x \<otimes> \<zero> = \<zero>" by (simp del: r_zero)
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   359
  qed auto
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   360
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   361
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   362
lemma l_minus:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   363
  "[| x \<in> carrier R; y \<in> carrier R |] ==> \<ominus> x \<otimes> y = \<ominus> (x \<otimes> y)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   364
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   365
  assume R: "x \<in> carrier R" "y \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   366
  then have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y = (\<ominus> x \<oplus> x) \<otimes> y" by (simp add: l_distr)
44677
3fb27b19e058 misc tuning and simplification of proofs;
wenzelm
parents: 41959
diff changeset
   367
  also from R have "... = \<zero>" by (simp add: l_neg)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   368
  finally have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y = \<zero>" .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   369
  with R have "(\<ominus> x) \<otimes> y \<oplus> x \<otimes> y \<oplus> \<ominus> (x \<otimes> y) = \<zero> \<oplus> \<ominus> (x \<otimes> y)" by simp
21896
9a7949815a84 Experimenting with interpretations of "definition".
ballarin
parents: 20318
diff changeset
   370
  with R show ?thesis by (simp add: a_assoc r_neg)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   371
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   372
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   373
lemma r_minus:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   374
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<otimes> \<ominus> y = \<ominus> (x \<otimes> y)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   375
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   376
  assume R: "x \<in> carrier R" "y \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   377
  then have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y = x \<otimes> (\<ominus> y \<oplus> y)" by (simp add: r_distr)
44677
3fb27b19e058 misc tuning and simplification of proofs;
wenzelm
parents: 41959
diff changeset
   378
  also from R have "... = \<zero>" by (simp add: l_neg)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   379
  finally have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y = \<zero>" .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   380
  with R have "x \<otimes> (\<ominus> y) \<oplus> x \<otimes> y \<oplus> \<ominus> (x \<otimes> y) = \<zero> \<oplus> \<ominus> (x \<otimes> y)" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   381
  with R show ?thesis by (simp add: a_assoc r_neg )
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   382
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   383
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   384
end
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   385
23957
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 23350
diff changeset
   386
lemma (in abelian_group) minus_eq:
54fab60ddc97 Interpretation of rings (as integers) maps defined operations to defined
ballarin
parents: 23350
diff changeset
   387
  "[| x \<in> carrier G; y \<in> carrier G |] ==> x \<ominus> y = x \<oplus> \<ominus> y"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   388
  by (simp only: a_minus_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   389
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   390
text \<open>Setup algebra method:
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   391
  compute distributive normal form in locale contexts\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   392
48891
c0eafbd55de3 prefer ML_file over old uses;
wenzelm
parents: 47701
diff changeset
   393
ML_file "ringsimp.ML"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   394
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   395
attribute_setup algebra = \<open>
58811
19382bbfa93a modernized setup;
wenzelm
parents: 55926
diff changeset
   396
  Scan.lift ((Args.add >> K true || Args.del >> K false) --| Args.colon || Scan.succeed true)
19382bbfa93a modernized setup;
wenzelm
parents: 55926
diff changeset
   397
    -- Scan.lift Args.name -- Scan.repeat Args.term
19382bbfa93a modernized setup;
wenzelm
parents: 55926
diff changeset
   398
    >> (fn ((b, n), ts) => if b then Ringsimp.add_struct (n, ts) else Ringsimp.del_struct (n, ts))
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   399
\<close> "theorems controlling algebra method"
47701
157e6108a342 more standard method setup;
wenzelm
parents: 47409
diff changeset
   400
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   401
method_setup algebra = \<open>
58811
19382bbfa93a modernized setup;
wenzelm
parents: 55926
diff changeset
   402
  Scan.succeed (SIMPLE_METHOD' o Ringsimp.algebra_tac)
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   403
\<close> "normalisation of algebraic structure"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   404
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   405
lemmas (in semiring) semiring_simprules
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   406
  [algebra ring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   407
  a_closed zero_closed  m_closed one_closed
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   408
  a_assoc l_zero  a_comm m_assoc l_one l_distr r_zero
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   409
  a_lcomm r_distr l_null r_null 
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   410
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   411
lemmas (in ring) ring_simprules
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   412
  [algebra ring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   413
  a_closed zero_closed a_inv_closed minus_closed m_closed one_closed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   414
  a_assoc l_zero l_neg a_comm m_assoc l_one l_distr minus_eq
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   415
  r_zero r_neg r_neg2 r_neg1 minus_add minus_minus minus_zero
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   416
  a_lcomm r_distr l_null r_null l_minus r_minus
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   417
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   418
lemmas (in cring)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   419
  [algebra del: ring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   420
  _
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   421
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   422
lemmas (in cring) cring_simprules
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   423
  [algebra add: cring "zero R" "add R" "a_inv R" "a_minus R" "one R" "mult R"] =
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   424
  a_closed zero_closed a_inv_closed minus_closed m_closed one_closed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   425
  a_assoc l_zero l_neg a_comm m_assoc l_one l_distr m_comm minus_eq
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   426
  r_zero r_neg r_neg2 r_neg1 minus_add minus_minus minus_zero
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   427
  a_lcomm m_lcomm r_distr l_null r_null l_minus r_minus
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   428
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   429
lemma (in semiring) nat_pow_zero:
67341
df79ef3b3a41 Renamed (^) to [^] in preparation of the move from "op X" to (X)
nipkow
parents: 67091
diff changeset
   430
  "(n::nat) \<noteq> 0 \<Longrightarrow> \<zero> [^] n = \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   431
  by (induct n) simp_all
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   432
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   433
context semiring begin
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   434
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   435
lemma one_zeroD:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   436
  assumes onezero: "\<one> = \<zero>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   437
  shows "carrier R = {\<zero>}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   438
proof (rule, rule)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   439
  fix x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   440
  assume xcarr: "x \<in> carrier R"
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   441
  from xcarr have "x = x \<otimes> \<one>" by simp
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   442
  with onezero have "x = x \<otimes> \<zero>" by simp
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   443
  with xcarr have "x = \<zero>" by simp
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   444
  then show "x \<in> {\<zero>}" by fast
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   445
qed fast
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   446
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   447
lemma one_zeroI:
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   448
  assumes carrzero: "carrier R = {\<zero>}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   449
  shows "\<one> = \<zero>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   450
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   451
  from one_closed and carrzero
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   452
      show "\<one> = \<zero>" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   453
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   454
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   455
lemma carrier_one_zero: "(carrier R = {\<zero>}) = (\<one> = \<zero>)"
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   456
  apply rule
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   457
   apply (erule one_zeroI)
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   458
  apply (erule one_zeroD)
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   459
  done
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   460
46721
f88b187ad8ca tuned proofs;
wenzelm
parents: 44677
diff changeset
   461
lemma carrier_one_not_zero: "(carrier R \<noteq> {\<zero>}) = (\<one> \<noteq> \<zero>)"
27717
21bbd410ba04 Generalised polynomial lemmas from cring to ring.
ballarin
parents: 27714
diff changeset
   462
  by (simp add: carrier_one_zero)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   463
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   464
end
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   465
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   466
text \<open>Two examples for use of method algebra\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   467
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   468
lemma
27611
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   469
  fixes R (structure) and S (structure)
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   470
  assumes "ring R" "cring S"
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   471
  assumes RS: "a \<in> carrier R" "b \<in> carrier R" "c \<in> carrier S" "d \<in> carrier S"
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   472
  shows "a \<oplus> \<ominus> (a \<oplus> \<ominus> b) = b \<and> c \<otimes>\<^bsub>S\<^esub> d = d \<otimes>\<^bsub>S\<^esub> c"
27611
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   473
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   474
  interpret ring R by fact
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   475
  interpret cring S by fact
27611
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   476
  from RS show ?thesis by algebra
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   477
qed
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   478
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   479
lemma
27611
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   480
  fixes R (structure)
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   481
  assumes "ring R"
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   482
  assumes R: "a \<in> carrier R" "b \<in> carrier R"
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   483
  shows "a \<ominus> (a \<ominus> b) = b"
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   484
proof -
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   485
  interpret ring R by fact
27611
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   486
  from R show ?thesis by algebra
2c01c0bdb385 Removed uses of context element includes.
ballarin
parents: 26202
diff changeset
   487
qed
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   488
35849
b5522b51cb1e standard headers;
wenzelm
parents: 35848
diff changeset
   489
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   490
subsubsection \<open>Sums over Finite Sets\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   491
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   492
lemma (in semiring) finsum_ldistr:
61384
9f5145281888 prefer symbols;
wenzelm
parents: 61382
diff changeset
   493
  "[| finite A; a \<in> carrier R; f \<in> A \<rightarrow> carrier R |] ==>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   494
   finsum R f A \<otimes> a = finsum R (%i. f i \<otimes> a) A"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 21896
diff changeset
   495
proof (induct set: finite)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   496
  case empty then show ?case by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   497
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   498
  case (insert x F) then show ?case by (simp add: Pi_def l_distr)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   499
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   500
59851
43b1870b3e61 added locale for semirings
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 58811
diff changeset
   501
lemma (in semiring) finsum_rdistr:
61384
9f5145281888 prefer symbols;
wenzelm
parents: 61382
diff changeset
   502
  "[| finite A; a \<in> carrier R; f \<in> A \<rightarrow> carrier R |] ==>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   503
   a \<otimes> finsum R f A = finsum R (%i. a \<otimes> f i) A"
22265
3c5c6bdf61de Adapted to changes in Finite_Set theory.
berghofe
parents: 21896
diff changeset
   504
proof (induct set: finite)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   505
  case empty then show ?case by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   506
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   507
  case (insert x F) then show ?case by (simp add: Pi_def r_distr)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   508
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   509
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   510
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   511
subsection \<open>Integral Domains\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   512
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   513
context "domain" begin
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   514
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   515
lemma zero_not_one [simp]:
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   516
  "\<zero> \<noteq> \<one>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   517
  by (rule not_sym) simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   518
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   519
lemma integral_iff: (* not by default a simp rule! *)
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   520
  "[| a \<in> carrier R; b \<in> carrier R |] ==> (a \<otimes> b = \<zero>) = (a = \<zero> \<or> b = \<zero>)"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   521
proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   522
  assume "a \<in> carrier R" "b \<in> carrier R" "a \<otimes> b = \<zero>"
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   523
  then show "a = \<zero> \<or> b = \<zero>" by (simp add: integral)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   524
next
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   525
  assume "a \<in> carrier R" "b \<in> carrier R" "a = \<zero> \<or> b = \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   526
  then show "a \<otimes> b = \<zero>" by auto
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   527
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   528
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   529
lemma m_lcancel:
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   530
  assumes prem: "a \<noteq> \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   531
    and R: "a \<in> carrier R" "b \<in> carrier R" "c \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   532
  shows "(a \<otimes> b = a \<otimes> c) = (b = c)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   533
proof
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   534
  assume eq: "a \<otimes> b = a \<otimes> c"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   535
  with R have "a \<otimes> (b \<ominus> c) = \<zero>" by algebra
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   536
  with R have "a = \<zero> \<or> (b \<ominus> c) = \<zero>" by (simp add: integral_iff)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   537
  with prem and R have "b \<ominus> c = \<zero>" by auto 
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   538
  with R have "b = b \<ominus> (b \<ominus> c)" by algebra 
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   539
  also from R have "b \<ominus> (b \<ominus> c) = c" by algebra
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   540
  finally show "b = c" .
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   541
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   542
  assume "b = c" then show "a \<otimes> b = a \<otimes> c" by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   543
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   544
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   545
lemma m_rcancel:
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   546
  assumes prem: "a \<noteq> \<zero>"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   547
    and R: "a \<in> carrier R" "b \<in> carrier R" "c \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   548
  shows conc: "(b \<otimes> a = c \<otimes> a) = (b = c)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   549
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   550
  from prem and R have "(a \<otimes> b = a \<otimes> c) = (b = c)" by (rule m_lcancel)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   551
  with R show ?thesis by algebra
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   552
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   553
41433
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   554
end
1b8ff770f02c Abelian group facts obtained from group facts via interpretation (sublocale).
ballarin
parents: 35849
diff changeset
   555
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   556
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   557
subsection \<open>Fields\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   558
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   559
text \<open>Field would not need to be derived from domain, the properties
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   560
  for domain follow from the assumptions of field\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   561
lemma (in cring) cring_fieldI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   562
  assumes field_Units: "Units R = carrier R - {\<zero>}"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   563
  shows "field R"
28823
dcbef866c9e2 tuned unfold_locales invocation
haftmann
parents: 27933
diff changeset
   564
proof
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   565
  from field_Units have "\<zero> \<notin> Units R" by fast
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   566
  moreover have "\<one> \<in> Units R" by fast
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   567
  ultimately show "\<one> \<noteq> \<zero>" by force
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   568
next
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   569
  fix a b
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   570
  assume acarr: "a \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   571
    and bcarr: "b \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   572
    and ab: "a \<otimes> b = \<zero>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   573
  show "a = \<zero> \<or> b = \<zero>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   574
  proof (cases "a = \<zero>", simp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   575
    assume "a \<noteq> \<zero>"
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   576
    with field_Units and acarr have aUnit: "a \<in> Units R" by fast
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   577
    from bcarr have "b = \<one> \<otimes> b" by algebra
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   578
    also from aUnit acarr have "... = (inv a \<otimes> a) \<otimes> b" by simp
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   579
    also from acarr bcarr aUnit[THEN Units_inv_closed]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   580
    have "... = (inv a) \<otimes> (a \<otimes> b)" by algebra
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   581
    also from ab and acarr bcarr aUnit have "... = (inv a) \<otimes> \<zero>" by simp
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   582
    also from aUnit[THEN Units_inv_closed] have "... = \<zero>" by algebra
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   583
    finally have "b = \<zero>" .
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   584
    then show "a = \<zero> \<or> b = \<zero>" by simp
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   585
  qed
23350
50c5b0912a0c tuned proofs: avoid implicit prems;
wenzelm
parents: 22265
diff changeset
   586
qed (rule field_Units)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   587
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   588
text \<open>Another variant to show that something is a field\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   589
lemma (in cring) cring_fieldI2:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   590
  assumes notzero: "\<zero> \<noteq> \<one>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   591
  and invex: "\<And>a. \<lbrakk>a \<in> carrier R; a \<noteq> \<zero>\<rbrakk> \<Longrightarrow> \<exists>b\<in>carrier R. a \<otimes> b = \<one>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   592
  shows "field R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   593
  apply (rule cring_fieldI, simp add: Units_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   594
  apply (rule, clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   595
  apply (simp add: notzero)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   596
proof (clarsimp)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   597
  fix x
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   598
  assume xcarr: "x \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   599
    and "x \<noteq> \<zero>"
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   600
  then have "\<exists>y\<in>carrier R. x \<otimes> y = \<one>" by (rule invex)
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   601
  then obtain y where ycarr: "y \<in> carrier R" and xy: "x \<otimes> y = \<one>" by fast
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   602
  from xy xcarr ycarr have "y \<otimes> x = \<one>" by (simp add: m_comm)
47409
c5be1120980d tuned proofs;
wenzelm
parents: 46721
diff changeset
   603
  with ycarr and xy show "\<exists>y\<in>carrier R. y \<otimes> x = \<one> \<and> x \<otimes> y = \<one>" by fast
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   604
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   605
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   606
61382
efac889fccbc isabelle update_cartouches;
wenzelm
parents: 60773
diff changeset
   607
subsection \<open>Morphisms\<close>
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   608
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
   609
definition
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   610
  ring_hom :: "[('a, 'm) ring_scheme, ('b, 'n) ring_scheme] => ('a => 'b) set"
35848
5443079512ea slightly more uniform definitions -- eliminated old-style meta-equality;
wenzelm
parents: 35847
diff changeset
   611
  where "ring_hom R S =
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   612
    {h. h \<in> carrier R \<rightarrow> carrier S \<and>
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   613
      (\<forall>x y. x \<in> carrier R \<and> y \<in> carrier R \<longrightarrow>
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   614
        h (x \<otimes>\<^bsub>R\<^esub> y) = h x \<otimes>\<^bsub>S\<^esub> h y \<and> h (x \<oplus>\<^bsub>R\<^esub> y) = h x \<oplus>\<^bsub>S\<^esub> h y) \<and>
35847
19f1f7066917 eliminated old constdefs;
wenzelm
parents: 35416
diff changeset
   615
      h \<one>\<^bsub>R\<^esub> = \<one>\<^bsub>S\<^esub>}"
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   616
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   617
lemma ring_hom_memI:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   618
  fixes R (structure) and S (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   619
  assumes hom_closed: "!!x. x \<in> carrier R ==> h x \<in> carrier S"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   620
    and hom_mult: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   621
      h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   622
    and hom_add: "!!x y. [| x \<in> carrier R; y \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   623
      h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   624
    and hom_one: "h \<one> = \<one>\<^bsub>S\<^esub>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   625
  shows "h \<in> ring_hom R S"
27714
27b4d7c01f8b Tuned (for the sake of a meaningless log entry).
ballarin
parents: 27699
diff changeset
   626
  by (auto simp add: ring_hom_def assms Pi_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   627
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   628
lemma ring_hom_closed:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   629
  "[| h \<in> ring_hom R S; x \<in> carrier R |] ==> h x \<in> carrier S"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   630
  by (auto simp add: ring_hom_def funcset_mem)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   631
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   632
lemma ring_hom_mult:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   633
  fixes R (structure) and S (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   634
  shows
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   635
    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   636
    h (x \<otimes> y) = h x \<otimes>\<^bsub>S\<^esub> h y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   637
    by (simp add: ring_hom_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   638
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   639
lemma ring_hom_add:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   640
  fixes R (structure) and S (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   641
  shows
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   642
    "[| h \<in> ring_hom R S; x \<in> carrier R; y \<in> carrier R |] ==>
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   643
    h (x \<oplus> y) = h x \<oplus>\<^bsub>S\<^esub> h y"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   644
    by (simp add: ring_hom_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   645
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   646
lemma ring_hom_one:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   647
  fixes R (structure) and S (structure)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   648
  shows "h \<in> ring_hom R S ==> h \<one> = \<one>\<^bsub>S\<^esub>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   649
  by (simp add: ring_hom_def)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   650
61565
352c73a689da Qualifiers in locale expressions default to mandatory regardless of the command.
ballarin
parents: 61384
diff changeset
   651
locale ring_hom_cring = R?: cring R + S?: cring S
29237
e90d9d51106b More porting to new locales.
ballarin
parents: 28823
diff changeset
   652
    for R (structure) and S (structure) +
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   653
  fixes h
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   654
  assumes homh [simp, intro]: "h \<in> ring_hom R S"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   655
  notes hom_closed [simp, intro] = ring_hom_closed [OF homh]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   656
    and hom_mult [simp] = ring_hom_mult [OF homh]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   657
    and hom_add [simp] = ring_hom_add [OF homh]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   658
    and hom_one [simp] = ring_hom_one [OF homh]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   659
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   660
lemma (in ring_hom_cring) hom_zero [simp]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   661
  "h \<zero> = \<zero>\<^bsub>S\<^esub>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   662
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   663
  have "h \<zero> \<oplus>\<^bsub>S\<^esub> h \<zero> = h \<zero> \<oplus>\<^bsub>S\<^esub> \<zero>\<^bsub>S\<^esub>"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   664
    by (simp add: hom_add [symmetric] del: hom_add)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   665
  then show ?thesis by (simp del: S.r_zero)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   666
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   667
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   668
lemma (in ring_hom_cring) hom_a_inv [simp]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   669
  "x \<in> carrier R ==> h (\<ominus> x) = \<ominus>\<^bsub>S\<^esub> h x"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   670
proof -
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   671
  assume R: "x \<in> carrier R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   672
  then have "h x \<oplus>\<^bsub>S\<^esub> h (\<ominus> x) = h x \<oplus>\<^bsub>S\<^esub> (\<ominus>\<^bsub>S\<^esub> h x)"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   673
    by (simp add: hom_add [symmetric] R.r_neg S.r_neg del: hom_add)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   674
  with R show ?thesis by simp
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   675
qed
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   676
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   677
lemma (in ring_hom_cring) hom_finsum [simp]:
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   678
  "f \<in> A \<rightarrow> carrier R \<Longrightarrow>
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   679
  h (finsum R f A) = finsum S (h \<circ> f) A"
60112
3eab4acaa035 finprod takes 1 in case of infinite sets => remove several "finite A" assumptions
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 59851
diff changeset
   680
  by (induct A rule: infinite_finite_induct, auto simp: Pi_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   681
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   682
lemma (in ring_hom_cring) hom_finprod:
67091
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   683
  "f \<in> A \<rightarrow> carrier R \<Longrightarrow>
1393c2340eec more symbols;
wenzelm
parents: 63167
diff changeset
   684
  h (finprod R f A) = finprod S (h \<circ> f) A"
60112
3eab4acaa035 finprod takes 1 in case of infinite sets => remove several "finite A" assumptions
Rene Thiemann <rene.thiemann@uibk.ac.at>
parents: 59851
diff changeset
   685
  by (induct A rule: infinite_finite_induct, auto simp: Pi_def)
20318
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   686
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   687
declare ring_hom_cring.hom_finprod [simp]
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   688
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   689
lemma id_ring_hom [simp]:
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   690
  "id \<in> ring_hom R R"
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   691
  by (auto intro!: ring_hom_memI)
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   692
0e0ea63fe768 Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
diff changeset
   693
end