src/HOL/Algebra/CRing.thy
author ballarin
Tue, 01 Apr 2003 16:08:34 +0200
changeset 13889 6676ac2527fa
parent 13864 f44f121dd275
child 13936 d3671b878828
permissions -rw-r--r--
Fixed Coset.thy (proved theorem factorgroup_is_group).
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
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
     8
theory CRing = Summation
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
     9
files ("ringsimp.ML"):
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    10
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    11
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
    12
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    13
subsection {* Basic Definitions *}
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    14
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    15
record 'a ring = "'a group" +
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    16
  zero :: 'a ("\<zero>\<index>")
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    17
  add :: "['a, 'a] => 'a" (infixl "\<oplus>\<index>" 65)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    18
  a_inv :: "'a => 'a" ("\<ominus>\<index> _" [81] 80)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    19
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    20
locale cring = abelian_monoid R +
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    21
  assumes a_abelian_group: "abelian_group (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    22
      mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    23
    and m_inv_def: "[| EX y. y \<in> carrier R & x \<otimes> y = \<one>; x \<in> carrier R |]
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    24
      ==> inv x = (THE y. y \<in> carrier R & x \<otimes> y = \<one>)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    25
    and l_distr: "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    26
      ==> (x \<oplus> y) \<otimes> z = x \<otimes> z \<oplus> y \<otimes> z"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    27
13889
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    28
text {* Derived operation. *}
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    29
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    30
constdefs
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    31
  minus :: "[('a, 'm) ring_scheme, 'a, 'a] => 'a" (infixl "\<ominus>\<index>" 65)
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    32
  "[| x \<in> carrier R; y \<in> carrier R |] ==> minus R x y == add R x (a_inv R y)"
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
    33
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    34
(*
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    35
  -- {* Definition of derived operations *}
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    36
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    37
  minus_def:    "a - b = a + (-b)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    38
  inverse_def:  "inverse a = (if a dvd 1 then THE x. a*x = 1 else 0)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    39
  divide_def:   "a / b = a * inverse b"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    40
  power_def:    "a ^ n = nat_rec 1 (%u b. b * a) n"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    41
*)
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    42
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    43
locale "domain" = cring +
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    44
  assumes one_not_zero [simp]: "\<one> ~= \<zero>"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    45
    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
    46
                  a = \<zero> | b = \<zero>"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    47
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    48
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
    49
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    50
lemma (in cring) a_magma [simp, intro]:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    51
  "magma (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    52
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    53
  using a_abelian_group by (simp only: abelian_group_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    54
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    55
lemma (in cring) a_l_one [simp, intro]:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    56
  "l_one (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    57
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    58
  using a_abelian_group by (simp only: abelian_group_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    59
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    60
lemma (in cring) a_abelian_group_parts [simp, intro]:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    61
  "semigroup_axioms (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    62
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    63
  "group_axioms (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    64
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    65
  "abelian_semigroup_axioms (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    66
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    67
  using a_abelian_group by (simp_all only: abelian_group_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    68
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    69
lemma (in cring) a_semigroup:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    70
  "semigroup (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    71
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    72
  by (simp add: semigroup_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    73
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    74
lemma (in cring) a_group:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    75
  "group (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    76
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    77
  by (simp add: group_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    78
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    79
lemma (in cring) a_abelian_semigroup:
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    80
  "abelian_semigroup (| carrier = carrier R,
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    81
     mult = add R, one = zero R, m_inv = a_inv R |)"
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    82
  by (simp add: abelian_semigroup_def)
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    83
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    84
lemmas group_record_simps = semigroup.simps monoid.simps group.simps
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
    85
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    86
lemmas (in cring) a_closed [intro, simp] =
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    87
  magma.m_closed [OF a_magma, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    88
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    89
lemmas (in cring) zero_closed [intro, simp] = 
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    90
  l_one.one_closed [OF a_l_one, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    91
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    92
lemmas (in cring) a_inv_closed [intro, simp] =
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    93
  group.inv_closed [OF a_group, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    94
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    95
lemma (in cring) minus_closed [intro, simp]:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    96
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<ominus> y \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    97
  by (simp add: minus_def)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
    98
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
    99
lemmas (in cring) a_l_cancel [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   100
  group.l_cancel [OF a_group, simplified group_record_simps]
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   101
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   102
lemmas (in cring) a_r_cancel [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   103
  group.r_cancel [OF a_group, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   104
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   105
lemmas (in cring) a_assoc =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   106
  semigroup.m_assoc [OF a_semigroup, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   107
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   108
lemmas (in cring) l_zero [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   109
  l_one.l_one [OF a_l_one, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   110
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   111
lemmas (in cring) l_neg =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   112
  group.l_inv [OF a_group, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   113
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   114
lemmas (in cring) a_comm =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   115
  abelian_semigroup.m_comm [OF a_abelian_semigroup,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   116
  simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   117
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   118
lemmas (in cring) a_lcomm =
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   119
  abelian_semigroup.m_lcomm [OF a_abelian_semigroup, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   120
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   121
lemma (in cring) r_zero [simp]:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   122
  "x \<in> carrier R ==> x \<oplus> \<zero> = x"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   123
  using group.r_one [OF a_group]
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   124
  by simp
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   125
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   126
lemma (in cring) r_neg:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   127
  "x \<in> carrier R ==> x \<oplus> (\<ominus> x) = \<zero>"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   128
  using group.r_inv [OF a_group]
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   129
  by simp
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   130
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   131
lemmas (in cring) minus_zero [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   132
  group.inv_one [OF a_group, simplified group_record_simps]
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   133
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   134
lemma (in cring) minus_minus [simp]:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   135
  "x \<in> carrier R ==> \<ominus> (\<ominus> x) = x"
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   136
  using group.inv_inv [OF a_group, simplified group_record_simps]
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   137
  by simp
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   138
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   139
lemma (in cring) minus_add:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   140
  "[| x \<in> carrier R; y \<in> carrier R |] ==> \<ominus> (x \<oplus> y) = \<ominus> x \<oplus> \<ominus> y"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   141
  using abelian_group.inv_mult [OF a_abelian_group]
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   142
  by simp
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   143
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   144
lemmas (in cring) a_ac = a_assoc a_comm a_lcomm
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   145
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   146
subsection {* Normaliser for Commutative Rings *}
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   147
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   148
lemma (in cring) r_neg2:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   149
  "[| x \<in> carrier R; y \<in> carrier R |] ==> x \<oplus> (\<ominus> x \<oplus> y) = y"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   150
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   151
  assume G: "x \<in> carrier R" "y \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   152
  then have "(x \<oplus> \<ominus> x) \<oplus> y = y" by (simp only: r_neg l_zero)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   153
  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
   154
qed
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   155
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   156
lemma (in cring) r_neg1:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   157
  "[| x \<in> carrier R; y \<in> carrier R |] ==> \<ominus> x \<oplus> (x \<oplus> y) = y"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   158
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   159
  assume G: "x \<in> carrier R" "y \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   160
  then have "(\<ominus> x \<oplus> x) \<oplus> y = y" by (simp only: l_neg l_zero)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   161
  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
   162
qed
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   163
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   164
lemma (in cring) r_distr:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   165
  "[| x \<in> carrier R; y \<in> carrier R; z \<in> carrier R |]
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   166
  ==> z \<otimes> (x \<oplus> y) = z \<otimes> x \<oplus> z \<otimes> y"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   167
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   168
  assume G: "x \<in> carrier R" "y \<in> carrier R" "z \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   169
  then have "z \<otimes> (x \<oplus> y) = (x \<oplus> y) \<otimes> z" by (simp add: m_comm)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   170
  also from G have "... = x \<otimes> z \<oplus> y \<otimes> z" by (simp add: l_distr)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   171
  also from G have "... = z \<otimes> x \<oplus> z \<otimes> y" by (simp add: m_comm)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   172
  finally show ?thesis .
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   173
qed
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   174
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   175
text {* 
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   176
  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
   177
*}
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   178
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   179
lemma (in cring) l_null [simp]:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   180
  "x \<in> carrier R ==> \<zero> \<otimes> x = \<zero>"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   181
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   182
  assume R: "x \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   183
  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
   184
    by (simp add: l_distr del: l_zero r_zero)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   185
  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
   186
  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
   187
  with R show ?thesis by (simp del: r_zero)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   188
qed
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   189
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   190
lemma (in cring) r_null [simp]:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   191
  "x \<in> carrier R ==> x \<otimes> \<zero> = \<zero>"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   192
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   193
  assume R: "x \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   194
  then have "x \<otimes> \<zero> = \<zero> \<otimes> x" by (simp add: ac)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   195
  also from R have "... = \<zero>" by simp
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   196
  finally show ?thesis .
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   197
qed
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   198
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   199
lemma (in cring) l_minus:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   200
  "[| 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
   201
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   202
  assume R: "x \<in> carrier R" "y \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   203
  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
   204
  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
   205
  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
   206
  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
   207
  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
   208
qed
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   209
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   210
lemma (in cring) r_minus:
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   211
  "[| 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
   212
proof -
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   213
  assume R: "x \<in> carrier R" "y \<in> carrier R"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   214
  then have "x \<otimes> \<ominus> y = \<ominus> y \<otimes> x" by (simp add: ac)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   215
  also from R have "... = \<ominus> (y \<otimes> x)" by (simp add: l_minus)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   216
  also from R have "... = \<ominus> (x \<otimes> y)" by (simp add: ac)
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   217
  finally show ?thesis .
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   218
qed
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   219
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   220
lemmas (in cring) cring_simprules =
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   221
  a_closed zero_closed a_inv_closed minus_closed m_closed one_closed
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   222
  a_assoc l_zero l_neg a_comm m_assoc l_one l_distr m_comm minus_def
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   223
  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
   224
  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
   225
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   226
use "ringsimp.ML"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   227
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   228
method_setup algebra =
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   229
  {* Method.ctxt_args cring_normalise *}
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   230
  {* computes distributive normal form in commutative rings (locales version) *}
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   231
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   232
text {* Two examples for use of method algebra *}
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   233
13854
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   234
lemma
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   235
  includes cring R + cring S
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   236
  shows "[| a \<in> carrier R; b \<in> carrier R; c \<in> carrier S; d \<in> carrier S |] ==> 
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   237
  a \<oplus> \<ominus> (a \<oplus> \<ominus> b) = b & c \<otimes>\<^sub>2 d = d \<otimes>\<^sub>2 c"
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   238
  by algebra
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   239
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   240
lemma
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   241
  includes cring
91c9ab25fece First distributed version of Group and Ring theory.
ballarin
parents: 13835
diff changeset
   242
  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
   243
  by algebra
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   244
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   245
subsection {* Sums over Finite Sets *}
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   246
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   247
text {*
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   248
  This definition makes it easy to lift lemmas from @{term finprod}.
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   249
*}
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   250
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   251
constdefs
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   252
  finsum :: "[('b, 'm) ring_scheme, 'a => 'b, 'a set] => 'b"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   253
  "finsum R f A == finprod (| carrier = carrier R,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   254
     mult = add R, one = zero R, m_inv = a_inv R |) f A"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   255
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   256
lemma (in cring) a_abelian_monoid:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   257
  "abelian_monoid (| carrier = carrier R,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   258
     mult = add R, one = zero R, m_inv = a_inv R |)"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   259
  by (simp add: abelian_monoid_def)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   260
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   261
(*
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   262
  lemmas (in cring) finsum_empty [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   263
    abelian_monoid.finprod_empty [OF a_abelian_monoid, simplified]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   264
  is dangeous, because attributes (like simplified) are applied upon opening
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   265
  the locale, simplified refers to the simpset at that time!!!
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   266
*)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   267
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   268
lemmas (in cring) finsum_empty [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   269
  abelian_monoid.finprod_empty [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   270
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   271
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   272
lemmas (in cring) finsum_insert [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   273
  abelian_monoid.finprod_insert [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   274
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   275
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   276
lemmas (in cring) finsum_zero =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   277
  abelian_monoid.finprod_one [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   278
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   279
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   280
lemmas (in cring) finsum_closed [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   281
  abelian_monoid.finprod_closed [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   282
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   283
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   284
lemmas (in cring) finsum_Un_Int =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   285
  abelian_monoid.finprod_Un_Int [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   286
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   287
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   288
lemmas (in cring) finsum_Un_disjoint =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   289
  abelian_monoid.finprod_Un_disjoint [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   290
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   291
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   292
lemmas (in cring) finsum_addf =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   293
  abelian_monoid.finprod_multf [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   294
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   295
13889
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
   296
lemmas (in cring) finsum_cong' =
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
   297
  abelian_monoid.finprod_cong' [OF a_abelian_monoid, folded finsum_def,
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   298
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   299
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   300
lemmas (in cring) finsum_0 [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   301
  abelian_monoid.finprod_0 [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   302
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   303
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   304
lemmas (in cring) finsum_Suc [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   305
  abelian_monoid.finprod_Suc [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   306
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   307
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   308
lemmas (in cring) finsum_Suc2 =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   309
  abelian_monoid.finprod_Suc2 [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   310
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   311
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   312
lemmas (in cring) finsum_add [simp] =
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   313
  abelian_monoid.finprod_mult [OF a_abelian_monoid, folded finsum_def,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   314
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   315
13889
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
   316
lemmas (in cring) finsum_cong =
6676ac2527fa Fixed Coset.thy (proved theorem factorgroup_is_group).
ballarin
parents: 13864
diff changeset
   317
  abelian_monoid.finprod_cong [OF a_abelian_monoid, folded finsum_def,
13864
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   318
    simplified group_record_simps]
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   319
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   320
text {*Usually, if this rule causes a failed congruence proof error,
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   321
   the reason is that the premise @{text "g \<in> B -> carrier G"} cannot be shown.
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   322
   Adding @{thm [source] Pi_def} to the simpset is often useful. *}
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   323
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   324
lemma (in cring) finsum_ldistr:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   325
  "[| finite A; a \<in> carrier R; f \<in> A -> carrier R |] ==>
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   326
   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
   327
proof (induct set: Finites)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   328
  case empty then show ?case by simp
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   329
next
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   330
  case (insert F x) then show ?case by (simp add: Pi_def l_distr)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   331
qed
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   332
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   333
lemma (in cring) finsum_rdistr:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   334
  "[| finite A; a \<in> carrier R; f \<in> A -> carrier R |] ==>
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   335
   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
   336
proof (induct set: Finites)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   337
  case empty then show ?case by simp
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   338
next
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   339
  case (insert F x) then show ?case by (simp add: Pi_def r_distr)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   340
qed
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   341
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   342
subsection {* Facts of Integral Domains *}
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   343
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   344
lemma (in "domain") zero_not_one [simp]:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   345
  "\<zero> ~= \<one>"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   346
  by (rule not_sym) simp
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   347
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   348
lemma (in "domain") integral_iff: (* not by default a simp rule! *)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   349
  "[| 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
   350
proof
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   351
  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
   352
  then show "a = \<zero> | b = \<zero>" by (simp add: integral)
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   353
next
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   354
  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
   355
  then show "a \<otimes> b = \<zero>" by auto
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   356
qed
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   357
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   358
lemma (in "domain") m_lcancel:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   359
  assumes prem: "a ~= \<zero>"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   360
    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
   361
  shows "(a \<otimes> b = a \<otimes> c) = (b = c)"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   362
proof
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   363
  assume eq: "a \<otimes> b = a \<otimes> c"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   364
  with R have "a \<otimes> (b \<ominus> c) = \<zero>" by algebra
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   365
  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
   366
  with prem and R have "b \<ominus> c = \<zero>" by auto 
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   367
  with R have "b = b \<ominus> (b \<ominus> c)" by algebra 
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   368
  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
   369
  finally show "b = c" .
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   370
next
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   371
  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
   372
qed
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   373
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   374
lemma (in "domain") m_rcancel:
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   375
  assumes prem: "a ~= \<zero>"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   376
    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
   377
  shows conc: "(b \<otimes> a = c \<otimes> a) = (b = c)"
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   378
proof -
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   379
  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
   380
  with R show ?thesis by algebra
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   381
qed
f44f121dd275 Bugs fixed and operators finprod and finsum.
ballarin
parents: 13854
diff changeset
   382
13835
12b2ffbe543a Change to meta simplifier: congruence rules may now have frees as head of term.
ballarin
parents:
diff changeset
   383
end