reserve n,k,b for Nat, i for Integer;

theorem Th16:
  for d being XFinSequence of INT, n being Integer st for i being Nat
  st i in dom d holds n divides d.i holds n divides Sum d
  proof
    let d be XFinSequence of INT, n be Integer such that
    A1: for i being Nat st i in dom d holds n divides d.i;
    per cases;
    suppose
      len d=0;
      then d={};
      then Sum d = 0;
      hence thesis by INT_2:12;
    end;
    suppose
      A2: len d > 0;
      then consider f being Function of NAT,INT such that
      A3: f.0 = d.0 and
      A4: for n being Nat st n+1 < len d holds
      f.(n + 1) = addint.(f.n,d.(n + 1)) and
      A5: addint "**" d = f.(len d-1) by AFINSQ_2:def 8;
      defpred P[Nat] means $1 < len d implies n divides f.$1;
      A6:
      now
        let k be Nat;
        assume A7: P[k];
        thus P[k+1]
        proof
          assume
          A8: k+1 < len d;
          then k+1 in Segm(len d) by NAT_1:44;
          then
          A9: n divides d.(k+1) by A1;
          f.(k+1) = addint.(f.k,d.(k+1)) by A4,A8
          .= f.k + d.(k+1) by BINOP_2:def 20;
          hence thesis by A7,A8,A9,XREAL_1:145,WSIERP_1:4;
        end;
      end;
      reconsider ld=len d-1 as Element of NAT by A2,NAT_1:20;
      A10: ld < len d by XREAL_1:147;
      0 in Segm dom d by NAT_1:44,A2; then
      A11: P[0] by A1,A3;
      A12: addint "**" d  = Sum d by AFINSQ_2:50;
      for k being Nat holds P[k] from NAT_1:sch 2(A11,A6);
      hence thesis by A5,A10,A12;
    end;
  end;
