reserve n for Nat,
        p,p1,p2 for Point of TOP-REAL n,
        x for Real;
reserve n,m for non zero Nat;
reserve i,j for Nat;
reserve f for PartFunc of REAL-NS m,REAL-NS n;
reserve g for PartFunc of REAL m,REAL n;
reserve h for PartFunc of REAL m,REAL;
reserve x for Point of REAL-NS m;
reserve y for Element of REAL m;
reserve X for set;

theorem Th26:
for n be non zero Nat, h,g be FinSequence of REAL n st
 len h = len g + 1 &
 (for i be Nat st i in dom g holds g/.i = h /.i - h/.(i+1)) holds
   h /.1 - h/.(len h) = Sum g
proof
   let n be non zero Nat,
       h,g be FinSequence of REAL n;
   assume that
A1: len h = len g + 1 and
A2: for i be Nat st i in dom g holds g/.i = h/.i - h/.(i+1);
   per cases;
   suppose A3: len g = 0;
    then h/.1 - h/.(len h) = 0*n by A1,EUCLIDLP:9;
    hence thesis by A3,EUCLID_7:def 11;
   end;
   suppose A4:len g > 0;
then A5: Sum g = (accum g).len g by EUCLID_7:def 11;
    defpred P[Nat] means $1 <= len g implies (accum g).$1 = h/.1 - h/.($1+1);
A6: P[1]
    proof
     assume 1 <= len g;
     then 1 in Seg len g;
then A7:  1 in dom g by FINSEQ_1:def 3;
      (accum g).1 = g.1 by EUCLID_7:def 10;
     then (accum g).1 = g/.1 by A7,PARTFUN1:def 6;
     hence (accum g).1 = h/.1 - h/.(1+1) by A7,A2;
    end;
A8: for j be Nat st 1 <= j holds P[j] implies P[j+1]
    proof
     let j be Nat;
     assume A9: 1 <= j;
     assume A10: P[j];
     assume A11:j+1 <= len g;
then A12:  j < len g by NAT_1:13;
      1 <= j+1 by XREAL_1:38;
then A13:  j+1 in dom g by A11,FINSEQ_3:25;
      len g = len (accum g) by EUCLID_7:def 10;
then A14:  j in dom (accum g) by A9,A12,FINSEQ_3:25;
      (accum g).(j+1) = (accum g)/.j + g/.(j+1) by A9,A12,EUCLID_7:def 10;
then A15: (accum g).(j+1) = (accum g)/.j + (h/.(j+1) - h/.(j+1+1))by A2,A13;
     reconsider hj1 = h/.(j+1) as Point of TOP-REAL n by EUCLID:22;
     reconsider hj2 = h/.(j+2) as Point of TOP-REAL n by EUCLID:22;
     reconsider hj3 = (h/.1 - h/.(j+1))as Point of TOP-REAL n by EUCLID:22;
      (accum g).(j+1) = hj3 + (hj1 - hj2)
       by A15,A10,A11,A14,NAT_1:13,PARTFUN1:def 6;
     then (accum g).(j+1) = hj3 + hj1 - hj2 by RLVECT_1:def 3;
     hence thesis by RVSUM_1:43;
    end;
A16:1 <= len g by A4,NAT_1:14;
     for i be Nat st 1 <= i holds P[i] from NAT_1:sch 8(A6,A8);
    hence thesis by A5,A1,A16;
   end;
end;
