reserve X,Y for set;
reserve R for domRing-like commutative Ring;
reserve c for Element of R;
reserve R for gcdDomain;

theorem Th40:
  for Amp being AmpleSet of R
  for r1,r2,s1,s2 being Element of R holds gcd(r1,r2,Amp) = 1.R &
    gcd(s1,s2,Amp) = 1.R & r2 <> 0.R implies
      gcd(((r1 * (s2/gcd(r2,s2,Amp))) + (s1 * (r2/gcd(r2,s2,Amp)))),
      (r2 * (s2/gcd(r2,s2,Amp))),Amp) = gcd(((r1 * (s2/gcd(r2,s2,Amp))) +
        (s1 * (r2/gcd(r2,s2,Amp)))), gcd(r2,s2,Amp),Amp)
proof
  let Amp be AmpleSet of R;
  let r1,r2,s1,s2 be Element of R;
  assume that
A1: gcd(r1,r2,Amp) = 1.R and
A2: gcd(s1,s2,Amp) = 1.R and
A3: r2 <> 0.R;
  set d = gcd(r2,s2,Amp);
  set r = r2/d;
  set s = s2/d;
A4: d <> 0.R by A3,Th33;
  then
A5: gcd(r,s,Amp) = 1.R by Th38;
A6: d divides s2 by Def12;
  gcd(s,s1,Amp) = 1.R
  proof
    gcd(s,s1,Amp) divides s by Def12;
    then consider e being Element of R such that
A7: gcd(s,s1,Amp) * e = s;
    gcd(s,s1,Amp) * (e * d) = s * d by A7,GROUP_1:def 3
      .= s2 by A6,A4,Def4;
    then
A8: gcd(s,s1,Amp) divides s2;
A9: gcd(s,s1,Amp) is Element of Amp & 1.R is Element of Amp by Def8,Def12;
    1.R * gcd(s,s1,Amp) = gcd(s,s1,Amp);
    then
A10: 1.R divides gcd(s,s1,Amp);
    gcd(s,s1,Amp) divides s1 by Def12;
    then gcd(s,s1,Amp) divides gcd(s1,s2,Amp) by A8,Def12;
    then gcd(s,s1,Amp) is_associated_to 1.R by A2,A10;
    hence thesis by A9,Th22;
  end;
  then
A11: gcd(s,(s1 * r),Amp) = gcd(s,r,Amp) by Th37;
  gcd(((r1 * s) + (s1 * r)),s,Amp) = gcd((s1 * r),s,Amp) by Th39;
  then
A12: gcd(((r1 * s) + (s1 * r)),s,Amp) = gcd(s,(s1 * r),Amp) by Th29
    .= 1.R by A11,A5,Th29;
A13: d divides (d * r2);
A14: d divides r2 by Def12;
  gcd(r,r1,Amp) = 1.R
  proof
    gcd(r,r1,Amp) divides r by Def12;
    then consider e being Element of R such that
A15: gcd(r,r1,Amp) * e = r;
    gcd(r,r1,Amp) * (e * d) = r * d by A15,GROUP_1:def 3
      .= r2 by A14,A4,Def4;
    then
A16: gcd(r,r1,Amp) divides r2;
A17: gcd(r,r1,Amp) is Element of Amp & 1.R is Element of Amp by Def8,Def12;
    1.R * gcd(r,r1,Amp) = gcd(r,r1,Amp);
    then
A18: 1.R divides gcd(r,r1,Amp);
    gcd(r,r1,Amp) divides r1 by Def12;
    then gcd(r,r1,Amp) divides gcd(r1,r2,Amp) by A16,Def12;
    then gcd(r,r1,Amp) is_associated_to 1.R by A1,A18;
    hence thesis by A17,Th22;
  end;
  then
A19: gcd(r,(r1 * s),Amp) = gcd(r,s,Amp) by Th37;
A20: gcd(((r1 * s) + (s1 * r)),r,Amp) = gcd((r1 * s),r,Amp) by Th39;
  gcd(r,s,Amp) = 1.R by A4,Th38;
  then
A21: gcd(((r1 * s) + (s1 * r)),(d * r),Amp) = gcd(((r1 * s) + (s1 * r)),d,
  Amp) by A20,A19,Th29,Th37;
  r2 * s = (1.R * r2) * s
    .= ((d/d) * r2) * s by A4,Th9
    .= ((d * r2)/d) * s by A4,A13,Th11
    .= s * (d * r) by A14,A4,A13,Th11;
  hence thesis by A12,A21,Th37;
end;
