reserve a,b,m,x,y,i1,i2,i3,i for Integer,
  k,p,q,n for Nat,
  c,c1,c2 for Element of NAT,
  z for set;
reserve fp,fp1 for FinSequence of NAT,

  b,c,d, n for Element of NAT,
  a for Nat;
reserve i,m,m1,m2,m3,r,s,a,b,c,c1,c2,x,y for Integer;

theorem
  for n1,n2,n3 being non zero Nat st (n1 gcd n2) divides (a-b
  ) holds ex r,s st for x st (x-a) mod n1=0 & (x-b) mod n2=0 & (x-c) mod n3=0
holds x,((a+n1*r)+(n1 lcm n2)*s) are_congruent_mod ((n1 lcm n2) lcm n3) & ((n1
div (n1 gcd n2))*r-((b-a) div (n1 gcd n2))) mod (n2 div (n1 gcd n2))=0 & (((n1
  lcm n2) div ((n1 lcm n2) gcd n3))*s-((c-(a+n1*r)) div ((n1 lcm n2) gcd n3)))
  mod (n3 div ((n1 lcm n2) gcd n3))=0
proof
  let n1,n2,n3 be non zero Nat;
  set d1 = (n1 gcd n2);
  set d2 = (n1 gcd n3);
  set d3 = (n2 gcd n3);
  set dd1 = n1 gcd n2;
  set K = n1 lcm n2;
A1: n2 divides (n1 lcm n2) by NAT_D:def 4;
  assume (n1 gcd n2) divides (a-b);
  then d1 divides -(a-b) by INT_2:10;
  then consider r such that
A2: for x st (x-a) mod n1=0 & (x-b) mod n2=0 holds x,(a+n1*r)
  are_congruent_mod K and
A3: ((n1 div dd1)*r - ((b-a) div dd1)) mod (n2 div dd1) = 0 by Th42;
  take r;
  set y = a + n1*r;
A4: (K div (K gcd n3)),(n3 div (K gcd n3)) are_coprime by Lm12;
  then consider s such that
A5: ( (K div (K gcd n3))*s - ((c-y) div (K gcd n3))) mod (n3 div (K gcd
  n3)) = 0 by Th15;
  take s;
A6: n1 divides (n1 lcm n2) by NAT_D:def 4;
A7: for x st (x - a) mod n1 = 0 & (x - b) mod n2 = 0 & (x - c) mod n3 = 0
  holds ((n1 lcm n2) gcd n3) divides (y-c)
  proof
    let x;
    assume that
A8: (x - a) mod n1 = 0 & (x - b) mod n2 = 0 and
A9: (x - c) mod n3 = 0;
A10: n3 divides (x - c) by A9,Lm10;
    x,y are_congruent_mod K by A2,A8;
    then K divides (x - y);
    then
A11: K divides -(x-y) by INT_2:10;
    then n1 divides (y - x) by A6,INT_2:9;
    then consider t1 being Integer such that
A12: (y-x) = n1 * t1;
    d3 divides n3 by NAT_D:def 5;
    then
A13: d3 divides (x - c) by A10,INT_2:9;
    d2 divides n3 by NAT_D:def 5;
    then
A14: d2 divides (x - c) by A10,INT_2:9;
    n2 divides (y - x) by A1,A11,INT_2:9;
    then consider t2 being Integer such that
A15: (y-x) = n2 * t2;
    d3 divides n2 by NAT_D:def 5;
    then
A16: d3 divides n2 * t2 by INT_2:2;
    y - c = (x - c) + n2 * t2 by A15;
    then
A17: d3 divides (y - c) by A16,A13,WSIERP_1:4;
    d2 divides n1 by NAT_D:def 5;
    then
A18: d2 divides n1 * t1 by INT_2:2;
    y - c = (x - c) + n1 * t1 by A12;
    then d2 divides (y - c) by A18,A14,WSIERP_1:4;
    then (d2 lcm d3) divides (y - c) by A17,INT_2:19;
    hence thesis by Th46;
  end;
  for x st (x-a) mod n1=0 & (x-b) mod n2=0 & (x-c) mod n3=0 holds x,(y +
  (n1 lcm n2)*s) are_congruent_mod ((n1 lcm n2) lcm n3)
  proof
A19: K <> 0 by INT_2:4;
    let x;
    assume that
A20: (x-a) mod n1=0 & (x-b) mod n2=0 and
A21: (x-c) mod n3=0;
    ((n1 lcm n2) gcd n3) divides (y-c) by A7,A20,A21;
    then (K gcd n3) divides -(y-c) by INT_2:10;
    then consider w being Integer such that
A22: for x st (x-y) mod K = 0 & (x-c) mod n3 = 0 holds x,(y + K*w)
    are_congruent_mod (K lcm n3) and
A23: ((K div (K gcd n3))*w - ((c-y) div (K gcd n3))) mod (n3 div (K
    gcd n3)) = 0 by A19,Th42;
A24: n3 = (n3 div (K gcd n3)) * (K gcd n3) by Lm11,INT_2:21;
    then n3 div (K gcd n3) <> 0;
    then w in Class(Cong(n3 div (K gcd n3)),s) by A4,A5,A23,Th26;
    then [s,w] in Cong(n3 div (K gcd n3)) by EQREL_1:18;
    then s,w are_congruent_mod (n3 div (K gcd n3)) by Def1;
    then
A25: K*s,K*w are_congruent_mod K*(n3 div (K gcd n3)) by Th10;
    K*(n3 div (K gcd n3)) = (K div (K gcd n3))*(K gcd n3)*(n3 div (K gcd
    n3)) by Lm11,INT_2:21
      .= n3*(K div (K gcd n3)) by A24;
    then K*s,K*w are_congruent_mod n3 by A25,INT_1:20;
    then
A26: n3 divides (K*s - K*w);
    K divides K*(s - w);
    then (K lcm n3) divides ((K*s + y) - (K*w + y)) by A26,INT_2:19;
    then (K*s + y),(K*w + y) are_congruent_mod (K lcm n3);
    then
A27: (K*w + y),(K*s + y) are_congruent_mod (K lcm n3) by INT_1:14;
    x,y are_congruent_mod K by A2,A20;
    then K divides (x - y);
    then (x - y) mod K = 0 by Lm10;
    then x,(K*w + y) are_congruent_mod (K lcm n3) by A21,A22;
    hence thesis by A27,INT_1:15;
  end;
  hence thesis by A3,A5;
end;
