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;

theorem
  len fp>=2 & (for b,c st b in dom fp & c in dom fp & b<>c holds (fp.b
gcd fp.c)=1) & (for b st b in dom fp holds fp.b <> 0) implies
 for fp1 ex x being Integer st
    for b st b in dom fp holds (x-fp1.b) mod fp.b = 0
proof
  assume that
A1: len fp>=2 and
A2: for b,c st b in dom fp & c in dom fp & b<>c holds (fp.b gcd fp.c)=1 and
A3: for b st b in dom fp holds fp.b <> 0;
  consider fp2 being FinSequence of NAT,q being Element of NAT such that
A4: fp=fp2^<*q*> by A1,FINSEQ_2:19;
  deffunc F(Nat) = {l where l is Element of NAT: ((Product Del(fp,$1))*l - 1)
  mod fp.$1 = 0};
  defpred FF[Nat,Nat] means $2 in F($1);
A5: for a be Nat st a in Seg len fp ex n being Element of NAT st FF[a,n]
  proof
    let a be Nat;
    reconsider l=fp.a as Integer;
    assume a in Seg len fp;
    then
A6: a in dom fp by FINSEQ_1:def 3;
    then Product Del(fp,a) gcd fp.a = 1 by A1,A2,Th31;
    then
A7: Product Del(fp,a),l are_coprime by INT_2:def 3;
    l <> 0 by A3,A6;
    then consider n being Nat such that
A8: ((Product Del(fp,a))*n-1) mod l = 0 by A7,Th16;
    reconsider n as Element of NAT by ORDINAL1:def 12;
    take n;
    thus thesis by A8;
  end;
  consider s being FinSequence of NAT such that
A9: dom s = Seg len fp & for a be Nat st a in Seg len fp holds FF[a,s.a
  ] from FINSEQ_1:sch 5(A5);
  let fp1;
  set k=len fp2;
  deffunc P(Nat) = Product Del(fp,$1)*(s.$1)*(fp1.$1);
  consider s1 being FinSequence such that
A10: len s1=k+1 & for a be Nat st a in dom s1 holds s1.a=P(a) from
  FINSEQ_1:sch 2;
  for a being Nat st a in dom s1 holds s1.a in NAT
  proof
    let a be Nat;
    assume
A11: a in dom s1;
    reconsider a as Element of NAT by ORDINAL1:def 12;
    s1.a = Product Del(fp,a)*(s.a)*(fp1.a) by A10,A11;
    hence thesis by ORDINAL1:def 12;
  end;
  then reconsider s1 as FinSequence of NAT by FINSEQ_2:12;
  set x = Sum s1;
  take x;
A12: len fp = k + 1 by A4,FINSEQ_2:16;
A13: for a,b st a in dom fp & b in dom fp & a<>b holds fp.b divides s1.a
  proof
    let a,b;
    assume that
A14: a in dom fp and
A15: b in dom fp & a<>b;
    len fp >= 1 by A1,XXREAL_0:2;
    then fp.b divides Product Del(fp,a)*((s.a)*(fp1.a)) by A14,A15,Th35,NAT_D:9
;
    then
A16: fp.b divides Product Del(fp,a)*(s.a)*(fp1.a);
    a in dom s1 by A12,A10,A14,FINSEQ_3:29;
    hence thesis by A10,A16;
  end;
A17: for b st b in dom fp holds fp.b divides Sum Del (s1,b)
  proof
    let b;
    assume
A18: b in dom fp;
    then b in Seg len s1 by A12,A10,FINSEQ_1:def 3;
    then
A19: b in dom s1 by FINSEQ_1:def 3;
    then
A20: len Del (s1,b) + 1 = k + 1 by A10,WSIERP_1:def 1;
    for a st a in dom Del (s1,b) holds fp.b divides Del (s1,b).a
    proof
      let a;
      assume
A21:  a in dom Del (s1,b);
      then
A22:  a>=1 & a<=k by A20,FINSEQ_3:25;
      dom Del (s1,b) c= dom s1 by WSIERP_1:39;
      then a in dom s1 by A21;
      then a in Seg (k+1) by A10,FINSEQ_1:def 3;
      then
A23:  a in dom fp by A12,FINSEQ_1:def 3;
      per cases;
      suppose
A24:    a<b;
        then Del (s1,b).a = s1.a by A19,WSIERP_1:def 1;
        hence thesis by A13,A18,A23,A24;
      end;
      suppose
A25:    a>=b;
        a+1<=k+1 & a+1>1 by A22,XREAL_1:6,29;
        then
A26:    a+1 in dom fp by A12,FINSEQ_3:25;
        Del (s1,b).a=s1.(a+1) & a+1>b by A19,A25,WSIERP_1:def 1,XREAL_1:39;
        hence thesis by A13,A18,A26;
      end;
    end;
    hence thesis by Th36;
  end;
  for b st b in dom fp holds (x-fp1.b) mod fp.b = 0
  proof
    let b;
    assume
A27: b in dom fp;
    then
A28: fp.b <>0 by A3;
A29: fp.b divides Sum Del (s1,b) by A17,A27;
A30: (Sum Del (s1,b)+((s1.b)-fp1.b)) mod fp.b = (s1.b - fp1.b) mod fp.b
    proof
      reconsider l = Sum Del (s1,b) as Integer;
A31:  l mod fp.b = 0 by A29,A28,INT_1:62;
      (Sum Del (s1,b)+((s1.b)-fp1.b)) mod fp.b = ((l mod fp.b) + (((s1.b)
      -fp1.b) mod fp.b)) mod fp.b by NAT_D:66
        .= ((s1.b)-fp1.b) mod fp.b by A31,NAT_D:65;
      hence thesis;
    end;
A32: b>=1 & b<=k+1 by A12,A27,FINSEQ_3:25;
    then
A33: b in Seg (k+1);
    then b in dom s1 by A10,FINSEQ_1:def 3;
    then
A34: s1.b - fp1.b = Product Del(fp,b)*(s.b)*(fp1.b) - 1*fp1.b by A10
      .= (Product Del(fp,b)*(s.b) - 1)*fp1.b;
    s.b in F(b) by A12,A9,A33;
    then
A35: ex ll being Element of NAT st ll = s.b & ((Product Del(fp,b))*ll-1)
    mod fp.b = 0;
A36: s1 is FinSequence of REAL by FINSEQ_2:24,NUMBERS:19;
    b in dom s1 by A10,A32,FINSEQ_3:25;
    then (x-fp1.b) mod fp.b = (Sum Del (s1,b)+(s1.b)-fp1.b) mod fp.b by
WSIERP_1:20,A36
      .= 0 by A28,A34,A35,A30,Lm9;
    hence thesis;
  end;
  hence thesis;
end;
