Theory Ring_ZF

(*
    This file is a part of IsarMathLib - 
    a library of formalized mathematics for Isabelle/Isar.

    Copyright (C) 2005, 2006  Slawomir Kolodynski

    This program is free software; Redistribution and use in source and binary forms, 
    with or without modification, are permitted provided that the following conditions are met:

   1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
   2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation and/or 
   other materials provided with the distribution.
   3. The name of the author may not be used to endorse or promote products 
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*)

section Rings - introduction

theory Ring_ZF imports AbelianGroup_ZF

begin

textThis theory file covers basic facts about rings.

subsectionDefinition and basic properties

textIn this section we define what is a ring and list the basic properties
  of rings.

textWe say that three sets $(R,A,M)$ form a ring if $(R,A)$ is an abelian 
  group, $(R,M)$ is a monoid and $A$ is distributive with respect to $M$ on 
  $R$. $A$ represents the additive operation on $R$. 
  As such it is a subset of $(R\times R)\times R$ (recall that in ZF set theory
  functions are sets).
  Similarly $M$ represents the multiplicative operation on $R$ and is also
  a subset of $(R\times R)\times R$.
  We  don't require the multiplicative operation to be commutative in the 
  definition of a ring.


definition
  "IsAring(R,A,M)  IsAgroup(R,A)  (A {is commutative on} R)  
  IsAmonoid(R,M)  IsDistributive(R,A,M)"

textWe also define the notion of having no zero divisors. In
  standard notation the ring has no zero divisors if for all $a,b \in R$ we have 
  $a\cdot b = 0$ implies $a = 0$ or $b = 0$.


definition
  "HasNoZeroDivs(R,A,M)  (aR. bR. 
  M` a,b = TheNeutralElement(R,A) 
  a = TheNeutralElement(R,A)  b = TheNeutralElement(R,A))"

textNext we define a locale that will be used when considering rings.

locale ring0 =

  fixes R and A and M 
 
  assumes ringAssum: "IsAring(R,A,M)"

  fixes ringa (infixl "\<ra>" 90)
  defines ringa_def [simp]: "x\<ra>y  A`x,y"

  fixes ringminus ("\<rm> _" 89)
  defines ringminus_def [simp]: "(\<rm>x)  GroupInv(R,A)`(x)"

  fixes ringsub (infixl "\<rs>" 90)
  defines ringsub_def [simp]: "x\<rs>y  x\<ra>(\<rm>y)"

  fixes ringm (infixl "" 95)
  defines ringm_def [simp]: "xy  M`x,y"

  fixes ringzero ("𝟬")
  defines ringzero_def [simp]: "𝟬  TheNeutralElement(R,A)"

  fixes ringone ("𝟭")
  defines ringone_def [simp]: "𝟭  TheNeutralElement(R,M)"

  fixes ringtwo ("𝟮")
  defines ringtwo_def [simp]: "𝟮  𝟭\<ra>𝟭"

  fixes ringsq ("_2" [96] 97)
  defines ringsq_def [simp]: "x2  xx"

textIn the ring0› context we can use theorems proven in some 
  other contexts.

lemma (in ring0) Ring_ZF_1_L1: shows 
  "monoid0(R,M)"
  "group0(R,A)" 
  "A {is commutative on} R"
  using ringAssum IsAring_def group0_def monoid0_def by auto

textThe theorems proven in in group0› context (locale) are valid
  in the ring0› context when applied to the additive group of the ring. 

sublocale ring0 < add_group: group0 R A ringzero ringa ringminus
  using Ring_ZF_1_L1(2) unfolding ringa_def ringminus_def ringzero_def by auto

textThe theorem proven in the monoid0› context are valid in the ring0› context 
  when applied to the multiplicative monoid of the ring.  

sublocale ring0 < mult_monoid: monoid0 R M ringm
  using Ring_ZF_1_L1(1) unfolding ringm_def by auto

textThe additive operation in a ring is distributive with respect to the
  multiplicative operation.

lemma (in ring0) ring_oper_distr: assumes A1: "aR"  "bR"  "cR"
  shows 
  "a(b\<ra>c) = ab \<ra> ac" 
  "(b\<ra>c)a = ba \<ra> ca"
  using ringAssum assms IsAring_def IsDistributive_def by auto

textZero and one of the ring are elements of the ring. The negative of zero
  is zero.

lemma (in ring0) Ring_ZF_1_L2: 
  shows "𝟬R"  "𝟭R"   "(\<rm>𝟬) = 𝟬"
  using add_group.group0_2_L2 mult_monoid.unit_is_neutral 
    add_group.group_inv_of_one by auto
  
textThe next lemma lists some properties of a ring that require one element
  of a ring.

lemma (in ring0) Ring_ZF_1_L3: assumes "aR"
  shows 
  "(\<rm>a)  R"
  "(\<rm>(\<rm>a)) = a"
  "a\<ra>𝟬 = a" 
  "𝟬\<ra>a = a" 
  "a𝟭 = a" 
  "𝟭a = a" 
  "a\<rs>a = 𝟬" 
  "a\<rs>𝟬 = a"
  "𝟮a = a\<ra>a"
  "(\<rm>a)\<ra>a = 𝟬"
  using assms add_group.inverse_in_group add_group.group_inv_of_inv 
    add_group.group0_2_L6 add_group.group0_2_L2 mult_monoid.unit_is_neutral 
    Ring_ZF_1_L2 ring_oper_distr
  by auto

textProperties that require two elements of a ring.

lemma (in ring0) Ring_ZF_1_L4: assumes A1: "aR" "bR"
  shows 
  "a\<ra>b  R" 
  "a\<rs>b  R" 
  "ab  R" 
  "a\<ra>b = b\<ra>a"
  using assms Ring_ZF_1_L1(3) Ring_ZF_1_L3 
    add_group.monoid.group0_1_L1 
    mult_monoid.group0_1_L1
    unfolding IsCommutative_def
  by auto

textCancellation of an element on both sides of equality. 
  This is a property of groups, written in the (additive) notation
  we use for the additive operation in rings.


lemma (in ring0) ring_cancel_add: 
  assumes A1: "aR" "bR" and A2: "a \<ra> b = a"
  shows "b = 𝟬"
  using assms add_group.group0_2_L7 by simp

textAny element of a ring multiplied by zero is zero.

lemma (in ring0) Ring_ZF_1_L6: 
  assumes A1: "xR" shows "𝟬x = 𝟬"   "x𝟬 = 𝟬"
proof -
  let ?a = "x𝟭"
  let ?b = "x𝟬"
  let ?c = "𝟭x"
  let ?d = "𝟬x"
  from A1 have 
    "?a \<ra> ?b = x(𝟭 \<ra> 𝟬)"   "?c \<ra> ?d = (𝟭 \<ra> 𝟬)x"
    using Ring_ZF_1_L2 ring_oper_distr by auto
  moreover have "x(𝟭 \<ra> 𝟬) = ?a" "(𝟭 \<ra> 𝟬)x = ?c"
    using Ring_ZF_1_L2 Ring_ZF_1_L3 by auto
  ultimately have "?a \<ra> ?b = ?a" and T1: "?c \<ra> ?d = ?c" 
    by auto
  moreover from A1 have 
    "?a  R"  "?b  R" and T2: "?c  R"  "?d  R"
    using Ring_ZF_1_L2 Ring_ZF_1_L4 by auto
  ultimately have "?b = 𝟬" using ring_cancel_add
    by blast
  moreover from T2 T1 have "?d = 𝟬" using ring_cancel_add
    by blast
  ultimately show "x𝟬 = 𝟬"  "𝟬x = 𝟬" by auto
qed

textNegative can be pulled out of a product.

lemma (in ring0) Ring_ZF_1_L7: 
  assumes A1: "aR"  "bR"
  shows 
  "(\<rm>a)b = \<rm>(ab)" 
  "a(\<rm>b) = \<rm>(ab)"
  "(\<rm>a)b = a(\<rm>b)"
proof -
  from A1 have I: 
    "ab  R" "(\<rm>a)  R" "((\<rm>a)b)  R" 
    "(\<rm>b)  R" "a(\<rm>b)  R"
    using Ring_ZF_1_L3 Ring_ZF_1_L4 by auto
  moreover have "(\<rm>a)b \<ra> ab = 𝟬" 
    and II: "a(\<rm>b) \<ra> ab = 𝟬"
  proof -
    from A1 I have 
      "(\<rm>a)b \<ra> ab = ((\<rm>a)\<ra> a)b"
      "a(\<rm>b) \<ra> ab= a((\<rm>b)\<ra>b)"
      using ring_oper_distr by auto
    moreover from A1 have 
      "((\<rm>a)\<ra> a)b = 𝟬" 
      "a((\<rm>b)\<ra>b) = 𝟬"
      using add_group.group0_2_L6 Ring_ZF_1_L6
      by auto
    ultimately show 
      "(\<rm>a)b \<ra> ab = 𝟬" 
      "a(\<rm>b) \<ra> ab = 𝟬" 
      by auto
  qed
  ultimately show "(\<rm>a)b = \<rm>(ab)"
    using add_group.group0_2_L9 by simp
  moreover from I II show "a(\<rm>b) = \<rm>(ab)"
    using add_group.group0_2_L9 by simp   
  ultimately show "(\<rm>a)b = a(\<rm>b)" by simp
qed

textMinus times minus is plus.

lemma (in ring0) Ring_ZF_1_L7A: assumes "aR"  "bR"
  shows "(\<rm>a)(\<rm>b) = ab"
  using assms Ring_ZF_1_L3 Ring_ZF_1_L7 Ring_ZF_1_L4
  by simp

textSubtraction is distributive with respect to multiplication.

lemma (in ring0) Ring_ZF_1_L8: assumes "aR"  "bR"  "cR"
  shows 
  "a(b\<rs>c) = ab \<rs> ac"  
  "(b\<rs>c)a = ba \<rs> ca"
  using assms Ring_ZF_1_L3 ring_oper_distr Ring_ZF_1_L7 Ring_ZF_1_L4
  by auto

textOther basic properties involving two elements of a ring.

lemma (in ring0) Ring_ZF_1_L9: assumes "aR"  "bR"
  shows 
  "(\<rm>b)\<rs>a = (\<rm>a)\<rs>b" 
  "(\<rm>(a\<ra>b)) = (\<rm>a)\<rs>b"  
  "(\<rm>(a\<rs>b)) = ((\<rm>a)\<ra>b)"
  "a\<rs>(\<rm>b) = a\<ra>b"
  using assms Ring_ZF_1_L1(3) add_group.group0_4_L4 add_group.group_inv_of_inv
  by auto

textIf the difference of two element is zero, then those elements
  are equal.

lemma (in ring0) Ring_ZF_1_L9A: 
  assumes A1: "aR"  "bR" and A2: "a\<rs>b = 𝟬"
  shows "a=b" using add_group.group0_2_L11A assms by auto

textOther basic properties involving three elements of a ring.

lemma (in ring0) Ring_ZF_1_L10: 
  assumes "aR"  "bR"  "cR"
  shows 
  "a\<ra>(b\<ra>c) = a\<ra>b\<ra>c"
  (*"a\<ra>(b\<rs>c) = a\<ra>b\<rs>c"*)
  "a\<rs>(b\<ra>c) = a\<rs>b\<rs>c"
  "a\<rs>(b\<rs>c) = a\<rs>b\<ra>c"
  using assms Ring_ZF_1_L1(3) add_group.group_oper_assoc 
    add_group.group0_4_L4A by auto

textAnother property with three elements.

lemma (in ring0) Ring_ZF_1_L10A: 
  assumes A1: "aR"  "bR"  "cR"
  shows "a\<ra>(b\<rs>c) = a\<ra>b\<rs>c"
  using assms Ring_ZF_1_L3 Ring_ZF_1_L10 by simp

textAssociativity of addition and multiplication.

lemma (in ring0) Ring_ZF_1_L11: 
  assumes "aR"  "bR"  "cR"
  shows 
  "a\<ra>b\<ra>c = a\<ra>(b\<ra>c)"
  "abc = a(bc)"
  using assms add_group.group_oper_assoc mult_monoid.sum_associative
  by auto

textAn interpretation of what it means that a ring has 
  no zero divisors.

lemma (in ring0) Ring_ZF_1_L12: 
  assumes "HasNoZeroDivs(R,A,M)"
  and "aR"  "a𝟬"  "bR"  "b𝟬"
  shows "ab𝟬" 
  using assms HasNoZeroDivs_def by auto

textIn rings with no zero divisors we can cancel nonzero factors.

lemma (in ring0) Ring_ZF_1_L12A: 
  assumes A1: "HasNoZeroDivs(R,A,M)" and A2: "aR"  "bR"  "cR"
  and A3: "ac = bc" and A4: "c𝟬" 
  shows "a=b"
proof -
  from A2 have T: "ac  R"  "a\<rs>b  R"
    using Ring_ZF_1_L4 by auto
  with A1 A2 A3 have "a\<rs>b = 𝟬  c=𝟬"
    using Ring_ZF_1_L3 Ring_ZF_1_L8 HasNoZeroDivs_def
    by simp
  with A2 A4 have "aR"  "bR"  "a\<rs>b = 𝟬" 
    by auto
  then show "a=b" by (rule Ring_ZF_1_L9A)
qed

textIn rings with no zero divisors if two elements are different, 
  then after multiplying by a nonzero element they are still different.

lemma (in ring0) Ring_ZF_1_L12B: 
  assumes A1: "HasNoZeroDivs(R,A,M)"  
  "aR"   "bR"   "cR"   "ab"   "c𝟬" 
  shows  "ac  bc"
  using A1 Ring_ZF_1_L12A by auto (* A1 has to be here *)

textIn rings with no zero divisors multiplying a nonzero element 
  by a nonone element changes the value.

lemma (in ring0) Ring_ZF_1_L12C:
  assumes A1: "HasNoZeroDivs(R,A,M)" and 
  A2: "aR"  "bR" and A3: "𝟬a"  "𝟭b"
  shows "a  ab"
proof -
  { assume "a = ab"
    with A1 A2 have "a = 𝟬  b\<rs>𝟭 = 𝟬"
      using Ring_ZF_1_L3 Ring_ZF_1_L2 Ring_ZF_1_L8 
	Ring_ZF_1_L3 Ring_ZF_1_L2 Ring_ZF_1_L4 HasNoZeroDivs_def
      by simp
    with A2 A3 have False
      using Ring_ZF_1_L2 Ring_ZF_1_L9A by auto
  } then show "a  ab" by auto
qed      

textIf a square is nonzero, then the element is nonzero.

lemma (in ring0) Ring_ZF_1_L13:
  assumes "aR"  and "a2  𝟬"
  shows "a𝟬"
  using assms Ring_ZF_1_L2 Ring_ZF_1_L6 by auto

textSquare of an element and its opposite are the same.

lemma (in ring0) Ring_ZF_1_L14:
  assumes "aR" shows "(\<rm>a)2 = ((a)2)"
  using assms Ring_ZF_1_L7A by simp

textAdding zero to a set that is closed under addition results
  in a set that is also closed under addition. This is a property of groups.

lemma (in ring0) Ring_ZF_1_L15: 
  assumes "H  R" and "H {is closed under} A"
  shows "(H  {𝟬}) {is closed under} A"
  using assms add_group.group0_2_L17 by simp

textAdding zero to a set that is closed under multiplication results
  in a set that is also closed under multiplication.

lemma (in ring0) Ring_ZF_1_L16:
  assumes A1: "H  R" and A2: "H {is closed under} M"
  shows "(H  {𝟬}) {is closed under} M"
  using assms Ring_ZF_1_L2 Ring_ZF_1_L6 IsOpClosed_def
  by auto

textThe ring is trivial iff $0=1$.

lemma (in ring0) Ring_ZF_1_L17: shows "R = {𝟬}  𝟬=𝟭"
proof
  assume "R = {𝟬}"
  then show "𝟬=𝟭" using Ring_ZF_1_L2
    by blast
next assume A1: "𝟬 = 𝟭"
  then have "R  {𝟬}"
    using Ring_ZF_1_L3 Ring_ZF_1_L6 by auto
  moreover have "{𝟬}  R" using Ring_ZF_1_L2 by auto
  ultimately show "R = {𝟬}" by auto
qed

textThe sets $\{m\cdot x. x\in R\}$ and  $\{-m\cdot x. x\in R\}$
  are the same.

lemma (in ring0) Ring_ZF_1_L18: assumes A1: "mR"
  shows "{mx. xR} = {(\<rm>m)x. xR}"
proof
  { fix a assume "a  {mx. xR}"
    then obtain x where "xR" and "a = mx"
      by auto
    with A1 have "(\<rm>x)  R"  and "a = (\<rm>m)(\<rm>x)" 
      using Ring_ZF_1_L3 Ring_ZF_1_L7A by auto
    then have "a  {(\<rm>m)x. xR}"
      by auto
  } then show "{mx. xR}  {(\<rm>m)x. xR}"
    by auto
next 
  { fix a assume "a  {(\<rm>m)x. xR}"
    then obtain x where "xR" and "a = (\<rm>m)x"
      by auto
    with A1 have "(\<rm>x)  R" and "a = m(\<rm>x)"
      using Ring_ZF_1_L3 Ring_ZF_1_L7 by auto
    then have "a  {mx. xR}" by auto
  } then show "{(\<rm>m)x. xR}  {mx. xR}"
    by auto
qed

subsectionRearrangement lemmas

textIn happens quite often that we want to show a fact like 
  $(a+b)c+d = (ac+d-e)+(bc+e)$in rings. 
  This is trivial in romantic math and probably there is a way to make 
  it trivial in formalized math. However, I don't know any other way than to
  tediously prove each such rearrangement when it is needed. This section 
  collects facts of this type.

textRearrangements with two elements of a ring.

lemma (in ring0) Ring_ZF_2_L1: assumes "aR" "bR" 
  shows "a\<ra>ba = (b\<ra>𝟭)a"
  using assms Ring_ZF_1_L2 ring_oper_distr Ring_ZF_1_L3 Ring_ZF_1_L4
  by simp

textRearrangements with two elements and cancelling.

lemma (in ring0) Ring_ZF_2_L1A: assumes "aR" "bR" 
  shows
  "a\<rs>b\<ra>b = a"
  "a\<ra>b\<rs>a = b"
  "(\<rm>a)\<ra>b\<ra>a = b"
  "(\<rm>a)\<ra>(b\<ra>a) = b"
  "a\<ra>(b\<rs>a) = b"
  using assms add_group.inv_cancel_two add_group.group0_4_L6A
    Ring_ZF_1_L1(3) by auto

textIn rings $a-(b+1)c = (a-d-c)+(d-bc)$ and $a+b+(c+d) = a+(b+c)+d$.

lemma (in ring0) Ring_ZF_2_L2: 
  assumes "aR"  "bR"  "cR"  "dR"
  shows 
    "a\<rs>(b\<ra>𝟭)c = (a\<rs>d\<rs>c)\<ra>(d\<rs>bc)"
    "a\<ra>b\<ra>(c\<ra>d) = a\<ra>b\<ra>c\<ra>d"
    "a\<ra>b\<ra>(c\<ra>d) = a\<ra>(b\<ra>c)\<ra>d"
proof -    
  let ?B = "bc"
  from ringAssum assms have
    "A {is commutative on} R" and "aR" "?B  R" "cR" "dR"
    unfolding IsAring_def using Ring_ZF_1_L4 by auto 
  then have 
    "a\<ra>(\<rm>?B\<ra>c) = a\<ra>(\<rm>d)\<ra>(\<rm>c)\<ra>(d\<ra>(\<rm>?B))"
    by (rule add_group.group0_4_L8)
  with assms show "a\<rs>(b\<ra>𝟭)c = (a\<rs>d\<rs>c)\<ra>(d\<rs>bc)"
    using Ring_ZF_1_L2 ring_oper_distr Ring_ZF_1_L3 by simp
  from assms show "a\<ra>b\<ra>(c\<ra>d) = a\<ra>b\<ra>c\<ra>d"
    using Ring_ZF_1_L4(1) Ring_ZF_1_L10(1) by simp
  with assms(1,2,3) show "a\<ra>b\<ra>(c\<ra>d) = a\<ra>(b\<ra>c)\<ra>d"
    using Ring_ZF_1_L10(1) by simp
qed

textRerrangement about adding linear functions.

lemma (in ring0) Ring_ZF_2_L3: 
  assumes A1: "aR"  "bR"  "cR"  "dR"  "xR"
  shows "(ax \<ra> b) \<ra> (cx \<ra> d) = (a\<ra>c)x \<ra> (b\<ra>d)"
proof -
  from A1 have
    "A {is commutative on} R"
    "ax  R"  "bR"  "cx  R"  "dR" 
    using Ring_ZF_1_L1 Ring_ZF_1_L4 by auto
  then have "A`A` ax,b,A` cx,d = A`A` ax,cx,A` b,d"
    using add_group.group0_4_L8(3) by auto
  with A1 show 
    "(ax \<ra> b) \<ra> (cx \<ra> d) = (a\<ra>c)x \<ra> (b\<ra>d)"
    using ring_oper_distr by simp
qed

textRearrangement with three elements

lemma (in ring0) Ring_ZF_2_L4: 
  assumes "M {is commutative on} R"
  and "aR"  "bR"  "cR"
  shows "a(bc) = acb" and "abc = acb"
  using assms IsCommutative_def Ring_ZF_1_L11
  by simp_all

textSome other rearrangements with three elements.

lemma (in ring0) ring_rearr_3_elemA:
  assumes A1: "M {is commutative on} R" and 
  A2: "aR"  "bR"  "cR"
  shows 
  "a(ac) \<rs> b(\<rm>bc) = (aa \<ra> bb)c"
  "a(\<rm>bc) \<ra> b(ac) = 𝟬"
proof -
  from A2 have T: 
    "bc  R"  "aa  R"  "bb  R"
    "b(bc)  R"  "a(bc)  R"
    using  Ring_ZF_1_L4 by auto
  with A2 show 
    "a(ac) \<rs> b(\<rm>bc) = (aa \<ra> bb)c"
    using Ring_ZF_1_L7 Ring_ZF_1_L3 Ring_ZF_1_L11 
      ring_oper_distr by simp
  from A2 T have 
    "a(\<rm>bc) \<ra> b(ac) = (\<rm>a(bc)) \<ra> bac"
    using Ring_ZF_1_L7 Ring_ZF_1_L11 by simp
  also from A1 A2 T have " = 𝟬"
    using IsCommutative_def Ring_ZF_1_L11 Ring_ZF_1_L3
    by simp
  finally show "a(\<rm>bc) \<ra> b(ac) = 𝟬"
    by simp
qed

textSome rearrangements with four elements. Properties of abelian groups.

lemma (in ring0) Ring_ZF_2_L5: 
  assumes "aR"  "bR"  "cR"  "dR"
  shows 
  "a \<rs> b \<rs> c \<rs> d = a \<rs> d \<rs> b \<rs> c"
  "a \<ra> b \<ra> c \<rs> d = a \<rs> d \<ra> b \<ra> c"
  "a \<ra> b \<rs> c \<rs> d = a \<rs> c \<ra> (b \<rs> d)"
  "a \<ra> b \<ra> c \<ra> d = a \<ra> c \<ra> (b \<ra> d)"
  using assms Ring_ZF_1_L1(3) add_group.rearr_ab_gr_4_elemB
    add_group.rearr_ab_gr_4_elemA by auto

textTwo big rearranegements with six elements, useful for
  proving properties of complex addition and multiplication.

lemma (in ring0) Ring_ZF_2_L6:
  assumes A1: "aR"  "bR"  "cR"  "dR"  "eR"  "fR"
  shows
  "a(ce \<rs> df) \<rs> b(cf \<ra> de) =
  (ac \<rs> bd)e \<rs> (ad \<ra> bc)f"
  "a(cf \<ra> de) \<ra> b(ce \<rs> df) =
  (ac \<rs> bd)f \<ra> (ad \<ra> bc)e"
  "a(c\<ra>e) \<rs> b(d\<ra>f) = ac \<rs> bd \<ra> (ae \<rs> bf)"
  "a(d\<ra>f) \<ra> b(c\<ra>e) = ad \<ra> bc \<ra> (af \<ra> be)"
proof -
  from A1 have T:
    "ce  R"  "df  R"  "cf  R"  "de  R"
    "ac  R"  "bd  R"  "ad  R"  "bc  R"
    "bf  R"  "ae  R"  "be  R"  "af  R"
    "ace  R"  "adf  R"
    "bcf  R"  "bde  R"
    "bce  R"  "bdf  R"
    "acf  R"  "ade  R"
    "ace \<rs> adf  R"
    "ace \<rs> bde  R"
    "acf \<ra> ade  R"
    "acf \<rs> bdf  R"
    "ac \<ra> ae  R"
    "ad \<ra> af  R"
    using Ring_ZF_1_L4 by auto
  with A1 show "a(ce \<rs> df) \<rs> b(cf \<ra> de) =
    (ac \<rs> bd)e \<rs> (ad \<ra> bc)f"
    using Ring_ZF_1_L8 ring_oper_distr Ring_ZF_1_L11
      Ring_ZF_1_L10 Ring_ZF_2_L5 by simp
  from A1 T show 
    "a(cf \<ra> de) \<ra> b(ce \<rs> df) =
    (ac \<rs> bd)f \<ra> (ad \<ra> bc)e"
    using Ring_ZF_1_L8 ring_oper_distr Ring_ZF_1_L11
    Ring_ZF_1_L10A Ring_ZF_2_L5 Ring_ZF_1_L10 
    by simp
  from A1 T show 
    "a(c\<ra>e) \<rs> b(d\<ra>f) = ac \<rs> bd \<ra> (ae \<rs> bf)"
    "a(d\<ra>f) \<ra> b(c\<ra>e) = ad \<ra> bc \<ra> (af \<ra> be)"
    using ring_oper_distr Ring_ZF_1_L10 Ring_ZF_2_L5
    by auto
qed

end