reserve i,j,n,n1,n2,m,k,l,u for Nat,
        i1,i2,i3,i4,i5,i6 for Element of n,
        p,q for n-element XFinSequence of NAT,
        a,b,c,d,e,f for Integer;

theorem Th1:
  for p being INT -valued Polynomial of n, F_Real
    for x,y being n-element XFinSequence of NAT st k<>0 &
      for i st i in n holds k divides (x.i - y.i) holds
  k divides (eval(p,@x) qua Integer) - (eval(p,@y) qua Integer)
proof
  let p be INT -valued Polynomial of n, F_Real;
  let x,y be n-element XFinSequence of NAT such that
A1: k<>0 and
A2: for i st i in n holds k divides (x.i - y.i);
  reconsider FR=F_Real as Field;
  reconsider pF=p as Polynomial of n, FR;
  reconsider xF=@x,yF=@y as Function of n, the carrier of FR;
  set sgmF=SgmX(BagOrder n,Support pF);
  set sgm=SgmX(BagOrder n,Support p);
  consider X be FinSequence of the carrier of FR such that
A3: len X = len sgmF & eval(pF,xF) = Sum X and
A4:  for i be Element of NAT st 1 <= i & i <= len X holds
  X/.i = (pF*sgmF)/.i * eval((sgmF/.i),xF) by POLYNOM2:def 4;
  consider Y be FinSequence of the carrier of FR such that
A5: len Y = len sgmF & eval(pF,yF) = Sum Y and
A6:  for i be Element of NAT st 1 <= i & i <= len Y holds
  Y/.i = (pF*sgmF)/.i * eval((sgmF/.i),yF) by POLYNOM2:def 4;
  reconsider Yr=Y,Xr=X as FinSequence of REAL;
  defpred P[Nat] means
    $1 <= len X implies Sum (Xr|$1) - Sum (Yr|$1) is Integer &
    for d be Integer st d=Sum (Xr|$1) - Sum (Yr|$1) holds k divides d;
A7: P[0] by INT_2:12;
A8: for i be Nat st P[i] holds P[i+1]
  proof
A9:   len (p*sgm) = len sgm by CARD_1:def 7;
    let i be Nat;
    assume
A10:  P[i];
    set i1=i+1;
    set O=(pF*sgmF)/.i1,O1=eval((sgmF/.i1),xF),O2 =eval((sgmF/.i1),yF);
    @x is INT -valued & @y is INT -valued by HILB10_2:def 1;
    then reconsider o1=O1,o2 =O2 as Integer;
    assume
A11:  i1 <= len X; then
    reconsider S= Sum (Xr|i) - Sum (Yr|i) as Integer by A10,NAT_1:13;
A12:  i1 in dom X by A11,NAT_1:11,FINSEQ_3:25;
    then
A13:  X|i1 = (X|i)^<*X.i1*> & X.i1 = X/.i1 & Xr.i1 = Xr/.i1
      by FINSEQ_5:10,PARTFUN1:def 6;
A14:  Sum (X|i) = Sum (Xr|i) by MATRPROB:36;
    dom (pF*sgmF) = dom X by A3,A9,FINSEQ_3:29;
    then (pF*sgmF).i1 = (pF*sgmF)/.i1 by A12,PARTFUN1:def 6;
    then reconsider o = O as Integer;
A15:  Sum (Xr|i1)= Sum (X|i1) by MATRPROB:36
        .= Sum (X|i) + Sum <*X/.i1*> by A13,RLVECT_1:41
        .= (addreal).(Sum (X|i),X/.i1) by RLVECT_1:44
        .= Sum (Xr|i) + (Xr/.i1) by A14,BINOP_2:def 9;
    i1 in dom Y by A11,NAT_1:11,FINSEQ_3:25,A3,A5;
    then
A16:  Y|i1 = (Y|i)^<*Y.i1*> & Y.i1 = Y/.i1 & Yr.i1 = Yr/.i1
      by FINSEQ_5:10,PARTFUN1:def 6;
A17:Sum (Y|i) = Sum (Yr|i) by MATRPROB:36;
A18: Sum (Yr|i1)= Sum (Y|i1) by MATRPROB:36
      .= Sum (Y|i) + Sum <*Y/.i1*> by A16,RLVECT_1:41
      .= (addreal).(Sum (Y|i),Y/.i1) by RLVECT_1:44
      .= Sum (Yr|i) + (Yr/.i1) by A17,BINOP_2:def 9;
A19:  Yr/.i1 = O * O2 by A3,A5,A6,A11,NAT_1:11;
    reconsider OO1= O * O1, OO2= O * O2, PS = (p*sgm)/.i1 as Element of F_Real;
A20:  (Xr/.i1) - (Yr/.i1) = OO1-OO2 by A4,A11,NAT_1:11,A19
        .= PS*(eval((sgmF/.i1),@x)-eval((sgmF/.i1),@y)) by VECTSP_1:11
        .= o * (o1-o2);
    k divides o1-o2
    proof
      set b=sgmF/.i1, SG=SgmX(RelIncl n, support b);
      consider H1 be FinSequence of FR such that
A21:    len H1 = len SG & eval(b,xF) = Product H1 and
A22:    for i being Element of NAT st 1 <= i & i <= len H1 holds
          H1/.i = power(FR).((xF * SG)/.i, (b * SG)/.i) by POLYNOM2:def 2;
      consider H2 be FinSequence of FR such that
A23:    len H2 = len SG & eval(b,yF) = Product H2 and
A24:    for i being Element of NAT st 1 <= i & i <= len H2 holds
          H2/.i = power(FR).((yF * SG)/.i, (b * SG)/.i) by POLYNOM2:def 2;
      defpred F[Nat] means $1 <= len SG implies Product (H1|$1) is integer &
        Product (H2|$1) is integer  &
        for i1,i2 be Integer st i1= Product (H1|$1) & i2 =Product (H2|$1) holds
        k divides i1-i2;
      reconsider ZERO=0 as Nat;
A25:  F[0]
      proof
        assume 0 <= len SG;
        H2|ZERO = <*>(the carrier of F_Real);
        then Product (H2|ZERO) = 1_ F_Real by GROUP_4:8
          .=1;
        hence thesis by INT_2:12;
      end;
A26:  for i be Nat st F[i] holds F[i+1]
      proof
        let i be Nat;
        assume
A27:      F[i];set i1=i+1,B=(b * SG)/.i1;
        assume
A28:      i1 <= len SG; then
        reconsider p1 = Product (H1|i),p2 = Product (H2|i) as Integer
          by A27,NAT_1:13;
A29:    i1 in dom SG by NAT_1:11,A28,FINSEQ_3:25;
A30:    len x = n & x = xF & y = yF by CARD_1:def 7,HILB10_2:def 1;
        rng SG c= n = dom xF & n = dom yF by PARTFUN1:def 2,RELAT_1:def 19;
        then i1 in dom (xF * SG) & i1 in dom (yF * SG) by A29,RELAT_1:27;
        then
A31:      (xF * SG)/.i1 = (xF * SG).i1 & (xF * SG).i1 = xF.(SG.i1) &
          (yF * SG)/.i1 = (yF * SG).i1 & (yF * SG).i1 = yF.(SG.i1) &
          SG.i1 in dom xF by PARTFUN1:def 6,FUNCT_1:11,12;
        then
A32:      SG.i1 in dom x by HILB10_2:def 1;
        set sg = SG.i1;
        reconsider xS = (xF * SG)/.i1,yS = (yF * SG)/.i1 as Integer by A31,A30;
        reconsider xfSG = (xF * SG)/.i1,yfSG = (yF * SG)/.i1
          as Element of F_Real;
        H1/.i1 = power(FR).((xF * SG)/.i1,B) by NAT_1:11,A22,A28,A21;
        then
A33:      H1/.i1 = xS |^B by NIVEN:7;
        H2/.i1 = power(FR).((yF * SG)/.i1,B) by NAT_1:11,A28,A23,A24;
        then
A34:      H2/.i1 = yS |^B by NIVEN:7;
        i1 in dom H1 by A28,NAT_1:11,FINSEQ_3:25,A21;
        then H1|i1 = (H1|i)^<*H1.i1*> & H1.i1 = H1/.i1
          by FINSEQ_5:10,PARTFUN1:def 6; then
A35:      Product (H1|i1) = Product (H1|i) * (H1/.i1) by GROUP_4:6
            .= p1 * (xS |^B) by A33,BINOP_2:def 11;
        i1 in dom H2 by A28,NAT_1:11,FINSEQ_3:25,A23;
        then H2|i1 = (H2|i)^<*H2.i1*> & H2.i1 = H2/.i1
          by FINSEQ_5:10,PARTFUN1:def 6;
        then
A36:      Product (H2|i1) = Product (H2|i) * (H2/.i1) by GROUP_4:6
            .= p2 * (yS |^B) by A34,BINOP_2:def 11;
        k divides (x.sg - y.sg) by A2,A31,A32;
        then
A37:      xS|^B,yS|^B are_congruent_mod k
          by A1,GR_CY_3:34,INT_1:def 4,A31,A30;
        k divides p1-p2 by NAT_1:13,A28,A27;
        then p1,p2 are_congruent_mod k by INT_1:def 4;
        hence thesis by A35,A36,INT_1:def 4,A37,INT_1:18;
      end;
      for i be Nat holds F[i] from NAT_1:sch 2(A25,A26);
      then F[len SG];
      hence thesis by A23,A21;
    end;
    then k divides o * (o1-o2) by INT_2:2;
    then
A38:  k divides -(o * (o1-o2)) by INT_2:10;
    k divides S by A10,A11,NAT_1:13;
    then k divides S --(o * (o1-o2)) by A38,INT_5:1;
    hence thesis by A18,A15,A20;
  end;
A39: P[i] from NAT_1:sch 2(A7,A8);
  Sum (Xr|len X) = eval(pF,xF) & Sum (Yr|len X) = eval(pF,yF)
    by A5,A3,MATRPROB:36;
  hence thesis by A39;
end;
