reserve i, j, m, n for Nat,
  z, B0 for set,
  f, x0 for real-valued FinSequence;

theorem Th33:
  for n being Element of NAT, f being FinSequence of REAL n, g
  being FinSequence of the carrier of (REAL-US n) st f=g holds Sum f=Sum g
proof
  let n be Element of NAT, f be FinSequence of REAL n, g be FinSequence of the
  carrier of (REAL-US n);
  set V=REAL-US n;
  assume
A1: f=g;
  now
    per cases;
    case
A2:   len f>0;
      set g2 = accum f;
A3:   len f=len g2 by Def10;
A4:   f.1=g2.1 by Def10;
A5:   Sum f=g2.(len f) by A2,Def11;
      deffunc F(set)=IFIN($1,len f+1,IFEQ($1,0, 0.V, g2/.$1),0.V);
A6:   for x being set st x in NAT holds F(x) in the carrier of V
      proof
        let x be set;
        assume x in NAT;
        then reconsider nx=x as Element of NAT;
        per cases;
        suppose
          nx in len f+1;
          then
A7:       F(x)=IFEQ(x,0, 0.V, g2/.nx) by MATRIX_7:def 1;
          per cases;
          suppose
            x=0;
            then F(x)=0.V by A7,FUNCOP_1:def 8;
            hence F(x) in the carrier of V;
          end;
          suppose
A8:         x<>0;
A9:        the carrier of V=REAL n by REAL_NS1:def 6;
            F(x)=g2/.nx by A7,A8,FUNCOP_1:def 8;
            hence F(x) in the carrier of V by A9;
          end;
        end;
        suppose
          not nx in len f +1;
          then F(x)=0.V by MATRIX_7:def 1;
          hence F(x) in the carrier of V;
        end;
      end;
      consider f3 being sequence of the carrier of V such that
A10:  for x being set st x in NAT holds f3.x = F(x) from FUNCT_2:sch
      11( A6);
A11:  for j being Nat for v being Element of V st j < len g &
      v = g . (j + 1) holds f3 . (j + 1) = (f3 . j) + v
      proof
       let j be Nat;
A12:     j in NAT by ORDINAL1:def 12;
        let v be Element of V;
        assume that
A13:    j < len g and
A14:    v = g . (j + 1);
A15:    j+1<=len f by A1,A13,NAT_1:13;
        per cases;
        suppose
A16:      j=0;
          then j+1<len f+1 by A2,XREAL_1:6;
          then
A17:      (j+1) in Segm(len f+1) by NAT_1:44;
A18:      0 in Segm(len f +1) by NAT_1:44;
A19:      f3.j=IFIN(j,len f+1,IFEQ(j,0, 0.V, g2/.j),0.V) by A10,A12
            .= IFEQ(j,0, 0.V, g2/.j) by A16,A18,MATRIX_7:def 1
            .= 0.V by A16,FUNCOP_1:def 8;
          thus f3.(j+1)=IFIN(j+1,len f+1,IFEQ(j+1,0, 0.V, g2/.(j+1)),0.V) by
A10
            .=IFEQ(j+1,0, 0.V, g2/.(j+1)) by A17,MATRIX_7:def 1
            .=g2/.1 by A16,FUNCOP_1:def 8
            .=g.(j+1) by A1,A3,A4,A15,A16,FINSEQ_4:15
            .= (f3.j)+v by A14,A19,RLVECT_1:4;
        end;
        suppose
A20:      j<>0;
          len f<len f+1 by XREAL_1:29;
          then j< len f+1 by A1,A13,XXREAL_0:2;
          then
A21:      j in Segm(len f +1) by NAT_1:44;
A22:      f3.j=IFIN(j,len f+1,IFEQ(j,0, 0.V, g2/.j),0.V) by A10,A12
            .= IFEQ(j,0, 0.V, g2/.j) by A21,MATRIX_7:def 1
            .= g2/.j by A20,FUNCOP_1:def 8;
A23:      0+1<=j+1 by NAT_1:13;
A24:      0+1<=j by A20,NAT_1:13;
          j+1<len f+1 by A1,A13,XREAL_1:6;
          then
A25:      (j+1) in Segm(len f+1) by NAT_1:44;
          thus f3.(j+1)=IFIN(j+1,len f+1,IFEQ(j+1,0, 0.V, g2/.(j+1)),0.V) by
A10
            .=IFEQ(j+1,0, 0.V, g2/.(j+1)) by A25,MATRIX_7:def 1
            .=g2/.(j+1) by FUNCOP_1:def 8
            .=g2.(j+1) by A3,A15,A23,FINSEQ_4:15
            .=(g2/.j)+(f/.(j+1)) by A1,Def10,A13,A24
            .=(f3.j)+v by A1,A14,A15,A23,A22,FINSEQ_4:15;
        end;
      end;
      len f <len f+1 by XREAL_1:29;
      then
A26:  len f in Segm(len f+1) by NAT_1:44;
A27:  0+1<=len f by A2,NAT_1:13;
A28:  0 in Segm(len f +1) by NAT_1:44;
A29:  f3.0=IFIN(0,len f+1,IFEQ(0,0, 0.V, g2/.0),0.V) by A10
        .=IFEQ(0,0, 0.V, g2/.0) by A28,MATRIX_7:def 1
        .=0.V by FUNCOP_1:def 8;
      f3.(len g)=F(len f) by A1,A10
        .=IFEQ(len f,0,0.V,g2/.(len f)) by A26,MATRIX_7:def 1
        .=g2/.(len f) by A2,FUNCOP_1:def 8
        .=Sum f by A3,A5,A27,FINSEQ_4:15;
      hence
      ex f2 being sequence of the carrier of V st Sum f = f2 . (len g
) & f2 . 0 = 0. V & for j being Nat for v being Element of V st j <
      len g & v = g . (j + 1) holds f2 . (j + 1) = (f2 . j) + v by A29,A11;
    end;
    case
A30:  len f<=0;
      set f3 = NAT --> 0.V;
A31:  for j being Nat for v being Element of V st j < len g &
      v = g . (j + 1) holds f3 . (j + 1) = (f3 . j) + v by A1,A30;
A32:  f3.(len g)=0.V by FUNCOP_1:7
        .= 0*n by REAL_NS1:def 6;
A33:  f3.0=0.V by FUNCOP_1:7;
      Sum f = 0*n by A30,Def11;
      hence
      ex f2 being sequence of the carrier of V st Sum f = f2 . (len g
) & f2 . 0 = 0. V & for j being Nat for v being Element of V st j <
      len g & v = g . (j + 1) holds f2 . (j + 1) = (f2 . j) + v by A32,A33,A31;
    end;
  end;
  hence Sum f=Sum g by RLVECT_1:def 12;
end;
