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