reserve R,R1 for commutative Ring;
reserve A,B for non degenerated commutative Ring;
reserve o,o1,o2 for object;
reserve r,r1,r2 for Element of R;
reserve a,a1,a2,b,b1 for Element of A;
reserve f for Function of R, R1;
reserve p for Element of Spectrum A;
reserve S for non empty multiplicatively-closed Subset of R;
reserve u,v,w,x,y,z for Element of Frac(S);
reserve a, b, c for Element of Frac(S);
reserve x, y, z for Element of S~R;

theorem Th40:
   S~R is Ring
   proof
A1:  x + y = y + x
     proof
       consider a such that
A2:    x = Class(EqRel(S),a) by Th32;
       consider b such that
A3:    y = Class(EqRel(S),b) by Th32;
       x+y = Class(EqRel(S),a+b) by A2,A3,Th35
        .= Class(EqRel(S),b+a)
        .= y + x by A2,A3,Th35;
      hence thesis;
     end;
A4:  (x + y) + z = x + (y + z)
     proof
       consider a such that
A5:    x = Class(EqRel(S),a) by Th32;
       consider b such that
A6:    y = Class(EqRel(S),b) by Th32;
       consider c such that
A7:    z = Class(EqRel(S),c) by Th32;
A8:    y+z = Class(EqRel(S),b+c) by A6,A7,Th35;
       x+y = Class(EqRel(S),a+b) by A5,A6,Th35; then
       (x+y) + z = Class(EqRel(S),(a+b)+c) by A7,Th35
       .= Class(EqRel(S),a+(b+c)) by Th19
       .= x + (y+z) by A8,A5,Th35;
       hence thesis;
     end;
A9:  x + 0.(S~R) = x
     proof
       consider a such that
A10:   x = Class(EqRel(S),a) by Th32;
       0.(S~R) = Class(EqRel(S),0.(R,S)) by Def6; then
       x + 0.(S~R) = Class(EqRel(S),a + 0.(R,S)) by A10,Th35
       .= x by A10;
       hence thesis;
     end;
A11: x is right_complementable
     proof
        ex y be Element of S~R st x+y = 0.(S~R)
        proof
        consider a, b being Element of Frac(S) such that
A12:    x = Class(EqRel(S),a) and
        0.(S~R) = Class(EqRel(S),b) and
        (the addF of S~R).(x,0.(S~R)) = Class(EqRel(S),a+b) by Def6;
        reconsider u1 = a`1 as Element of R;
        reconsider u2 = a`2 as Element of S by Lm17;
        reconsider u = [-u1,u2] as Element of Frac(S) by Def3;
A13:    a + u = [u1*u2 + (-u1*u2), u2*u2] by VECTSP_1:9
             .= [0.R, u2*u2] by RLVECT_1:5;
        reconsider s = 1.R as Element of S by C0SP1:def 4;
        reconsider u3 = u2*u2 as Element of S by C0SP1:def 4;
        (0.R * 1.R - 0.R * u3) * s = 0.R; then
        a+u,0.(R,S) Fr_Eq S by A13; then
A14:    Class(EqRel(S),a+u) = Class(EqRel(S),0.(R,S)) by Th26
        .= 0.(S~R) by Def6;
A15:    the carrier of S~R = Class EqRel(S) by Def6;
        reconsider y = Class(EqRel(S),u) as Element of S~R
        by A15,EQREL_1:def 3;
        x + y = 0.(S~R) by A14,A12,Th35;
        hence thesis;
      end;
      hence thesis;
     end;
A16: (x + y) * z = x * z + y * z
     proof
       consider a such that
A17:   x = Class(EqRel(S),a) by Th32;
       consider b such that
A18:   y = Class(EqRel(S),b) by Th32;
       consider c such that
A19:   z = Class(EqRel(S),c) by Th32;
A21:   x*z = Class(EqRel(S),a*c) by A17,A19,Th33;
A22:   y*z = Class(EqRel(S),b*c) by A18,A19,Th33;
       x+y = Class(EqRel(S),a+b) by A17,A18,Th35; then
       (x+y)*z = Class(EqRel(S),(a+b)*c) by A19,Th33
       .= Class(EqRel(S),a*c+ b*c) by Th29,Th26 .= x*z+ y*z by A21,A22,Th35;
       hence thesis;
     end;
A23: x * (y + z) = x * y + x * z & (y + z) * x = y * x + z * x
     proof
       x * (y + z) = (y + z) * x by Th34 .= y*x + z* x by A16
       .= x*y + z* x by Th34 .= x*y + x*z by Th34;
       hence thesis by A16;
     end;
A25: (x * y) * z = x * (y * z)
     proof
       consider a such that
A26:   x = Class(EqRel(S),a) by Th32;
       consider b such that
A27:   y = Class(EqRel(S),b) by Th32;
       consider c such that
A28:   z = Class(EqRel(S),c) by Th32;
A29:   y*z = Class(EqRel(S),b*c) by A27,A28,Th33;
       x*y = Class(EqRel(S),a*b) by A26,A27,Th33; then
       (x*y)*z = Class(EqRel(S),(a*b)*c) by A28,Th33
       .= Class(EqRel(S),a*(b*c)) by Th20  .= x*(y*z) by A26,A29,Th33;
       hence thesis;
     end;
     x *1.(S~R) = x & 1.(S~R) * x = x
     proof
       consider a such that
A30:   x = Class(EqRel(S),a) by Th32;
       1.(S~R) = Class(EqRel(S),1.(R,S)) by Def6; then
       x * 1.(S~R) = Class(EqRel(S),a * 1.(R,S)) by A30,Th33 .= x by A30;
       hence thesis by Th34;
     end;
     hence thesis by A1,A4,A9,A11,A23,A25,VECTSP_1:def 6,def 7,
     GROUP_1:def 3,RLVECT_1:def 2,def 3,def 4,ALGSTR_0:def 16;
   end;
