reserve

  k,n,m,i,j for Element of NAT,
  K for Field;
reserve L for non empty addLoopStr;
reserve G for non empty multLoopStr;

theorem Th32:
  for x being FinSequence of K, a being Element of K st (ex i st 1
<=i & i<=len x & x.i=a & (for j st j<>i & 1<=j & j<=len x holds x.j=0.K)) holds
  Sum x=a
proof
  let x be FinSequence of K, a be Element of K;
  given i such that
A1: 1<=i and
A2: i<=len x and
A3: x.i=a and
A4: for j st j<>i & 1<=j & j<=len x holds x.j=0.K;
  1<=len x by A1,A2,XXREAL_0:2;
  then consider f being sequence of (the carrier of K) such that
A5: f.1 = x.1 and
A6: for n being Nat st 0 <> n & n < len x
    holds f.(n + 1) = (the addF of K).(f.n,x.(n + 1)) and
A7: (the addF of K) "**" x = f.(len x) by FINSOP_1:def 1;
A8: for j being Nat st 1<=j & j<i holds f.j=0.K
  proof
    defpred P[Nat] means 1<=$1 & $1<i implies f.$1=0.K;
    let j be Nat;
    assume
A9: 1<=j & j<i;
A10: for k being Nat st P[k] holds P[k+1]
    proof
      let k be Nat;
      assume
A11:  P[k];
      per cases;
      suppose
A12:    not(1<=k & k<i);
        now
          per cases by A12;
          suppose
A13:        1>k;
A14:        1<=1+k by NAT_1:12;
            1>=k+1 by A13,NAT_1:13;
            then
A15:        k+1=1 by A14,XXREAL_0:1;
            now
              per cases;
              suppose
                k+1<i;
                then k+1< len x by A2,XXREAL_0:2;
                hence thesis by A4,A5,A15;
              end;
              suppose
                k+1>=i;
                hence thesis;
              end;
            end;
            hence thesis;
          end;
          suppose
            k>=i;
            hence thesis by NAT_1:12;
          end;
        end;
        hence thesis;
      end;
      suppose
A16:    1<=k & k<i;
        then
A17:    k+1<=i by NAT_1:13;
A18:    k<len x by A2,A16,XXREAL_0:2;
        now
          per cases by A17,XXREAL_0:1;
          suppose
A19:        k+1<i;
            then
A20:        k+1< len x by A2,XXREAL_0:2;
            f.(k + 1) = (the addF of K).(f.k,x.(k + 1)) by A6,A16,A18
              .= 0.K+0.K by A4,A11,A16,A19,A20,NAT_1:12
              .= 0.K by RLVECT_1:4;
            hence thesis;
          end;
          suppose
            k+1=i;
            hence thesis;
          end;
        end;
        hence thesis;
      end;
    end;
A21: P[0];
    for l being Nat holds P[l] from NAT_1:sch 2(A21,A10);
    hence thesis by A9;
  end;
  for j st i<=j & j<=len x holds f.j=a
  proof
    defpred P[Nat] means i<=$1 & $1<=len x implies f.$1=a;
    let j;
    assume
A22: i<=j & j<=len x;
A23: for k being Nat st P[k] holds P[k+1]
    proof
      let k be Nat;
      assume
A24:  P[k];
      per cases;
      suppose
        not(i<=k+1 & k+1<=len x);
        hence thesis;
      end;
      suppose
A25:    i<=k+1 & k+1<=len x;
        then
A26:    k<len x by NAT_1:13;
A27:    1<=k+1 by A1,A25,XXREAL_0:2;
        now
          per cases by A25,XXREAL_0:1;
          suppose
A28:        i<k+1;
A29:        k<len x by A25,NAT_1:13;
            i<=k by A28,NAT_1:13;
            then f.(k + 1) = (the addF of K).(f.k,x.(k + 1)) by A1,A6,A29
              .= a+0.K by A4,A24,A25,A27,A28,NAT_1:13
              .= a by RLVECT_1:4;
            hence thesis;
          end;
          suppose
A30:        i=k+1;
            then
A31:        k<i by NAT_1:13;
            now
              per cases;
              suppose
A32:            1<=k;
                then f.(k + 1) = (the addF of K).(f.k,x.(k + 1)) by A6,A26
                  .= 0.K+a by A3,A8,A30,A31,A32
                  .= a by RLVECT_1:4;
                hence thesis;
              end;
              suppose
                k<1;
                then
A33:            k+1<=1 by NAT_1:13;
                1<=1+k by NAT_1:12;
                then i=1 by A30,A33,XXREAL_0:1;
                hence thesis by A3,A5,A33,XXREAL_0:1;
              end;
            end;
            hence thesis;
          end;
        end;
        hence thesis;
      end;
    end;
A34: P[0] by A1;
    for l being Nat holds P[l] from NAT_1:sch 2(A34,A23);
    hence thesis by A22;
  end;
  then f.(len x)=a by A2;
  hence thesis by A7,FVSUM_1:def 8;
end;
