
theorem Th1:
  for n,m be Nat, a be Function of [:Seg n,Seg m:],REAL for p,q
be FinSequence of REAL st ( dom p=Seg n & for i be Nat st i in dom p holds ex r
  be FinSequence of REAL st (dom r = Seg m & p.i = Sum r & for j be Nat st j in
dom r holds r.j=a.[i,j])) & ( dom q=Seg m & for j be Nat st j in dom q holds ex
s be FinSequence of REAL st (dom s = Seg n & q.j = Sum s & for i be Nat st i in
  dom s holds s.i=a.[i,j])) holds Sum p = Sum q
proof
  defpred P[Nat] means for m be Nat, a be Function of [: Seg $1, Seg m :],REAL
  for p,q be FinSequence of REAL st (dom p=Seg $1 & for i be Nat st i in dom p
  holds ex r be FinSequence of REAL st (dom(r) = Seg m & p.i=Sum(r) & for j be
Nat st j in dom(r) holds r.j=a.[i,j] )) & ( dom q=Seg m & for j be Nat st j in
dom q holds ex s be FinSequence of REAL st (dom(s) = Seg $1 & q.j=Sum(s) & for
  i be Nat st i in dom(s) holds s.i=a.[i,j])) holds Sum(p)=Sum(q);
A1: for n be Nat st P[n] holds P[n+1]
  proof
    let n be Nat such that
A2: P[n];
    reconsider n as Element of NAT by ORDINAL1:def 12;
    now
      let m be Nat, a be Function of [:Seg (n+1),Seg m :],REAL;
      let p,q be FinSequence of REAL such that
A3:   dom p=Seg (n+1) and
A4:   for i be Nat st i in dom p holds ex r be FinSequence of REAL st
( dom(r) = Seg m & p.i=Sum(r) & for j be Nat st j in dom(r) holds r.j=a.[i,j])
      and
A5:   dom q=Seg m and
A6:   for j be Nat st j in dom q holds ex s be FinSequence of REAL st
( dom s = Seg (n+1) & q.j=Sum s & for i be Nat st i in dom s holds s.i=a.[i,j]
      );
      set a0=a| [:Seg n, Seg m :];
      n <= n+1 by NAT_1:11;
      then Seg n c= Seg (n+1) by FINSEQ_1:5;
      then [:Seg n,Seg m:] c= [:Seg (n+1),Seg m:] by ZFMISC_1:95;
      then reconsider a0 as Function of [:Seg n,Seg m :],REAL by FUNCT_2:32;
      deffunc F(Nat)=a.[n+1,$1];
      reconsider p0= p | (Seg n) as FinSequence of REAL by FINSEQ_1:18;
      n+1 in NAT by ORDINAL1:def 12;
      then len p=n+1 by A3,FINSEQ_1:def 3;
      then
A7:   n <= len p by NAT_1:11;
      then
A8:   dom p0=Seg n by FINSEQ_1:17;
A9:   dom p0=Seg n by A7,FINSEQ_1:17;
A10:  now
        let i be Nat such that
A11:    i in dom p0;
        consider r be FinSequence of REAL such that
A12:    dom(r) = Seg m and
A13:    p.i=Sum(r) and
A14:    for j be Nat st j in dom(r) holds r.j=a.[i,j] by A3,A4,A9,A11,
FINSEQ_2:8;
        take r;
        thus dom(r) = Seg m by A12;
        thus p0.i = Sum(r) by A11,A13,FUNCT_1:47;
        thus for j be Nat st j in dom(r) holds r.j=a0.[i,j]
        proof
          n <= n+1 by NAT_1:11;
          then
A15:      Seg n c= Seg (n+1) by FINSEQ_1:5;
          dom a= [:Seg (n+1),Seg m:] by FUNCT_2:def 1;
          then
A16:      dom a0 = [:Seg (n+1),Seg m:] /\ [:Seg n,Seg m:] by RELAT_1:61
            .= [:Seg n,Seg m:] by A15,ZFMISC_1:101;
          let j be Nat such that
A17:      j in dom(r);
A18:      [i,j] in [:Seg n,Seg m:] by A9,A11,A12,A17,ZFMISC_1:87;
          thus r.j=a.[i,j] by A14,A17
            .=a0.[i,j] by A18,A16,FUNCT_1:47;
        end;
      end;
      reconsider m as Element of NAT by ORDINAL1:def 12;
      consider an be FinSequence such that
A19:  len an=m & for j be Nat st j in dom an holds an.j=F(j) from
      FINSEQ_1:sch 2;
A20:  now
        let i be Nat;
        assume i in dom an;
        then an.i = a.[n+1,i] by A19;
        hence an.i in REAL by XREAL_0:def 1;
      end;
A21:  dom an = Seg m by A19,FINSEQ_1:def 3;
      reconsider an as FinSequence of REAL by A20,FINSEQ_2:12;
A22:  an is Element of m-tuples_on REAL by A19,FINSEQ_2:92;
A23:  dom an=Seg m by A19,FINSEQ_1:def 3;
A24:  Sum(an) = p.(n+1)
      proof
        consider r be FinSequence of REAL such that
A25:    dom(r) = Seg m and
A26:    p.(n+1)=Sum(r) and
A27:    for j be Nat st j in dom(r) holds r.j=a.[n+1,j] by A3,A4,FINSEQ_1:4;
        now
          let j be Nat;
          assume
A28:      j in dom r;
          hence r.j=a.[n+1,j] by A27
            .=an.j by A19,A21,A25,A28;
        end;
        hence thesis by A23,A25,A26,FINSEQ_1:13;
      end;
      reconsider q0=q-an as FinSequence of REAL;
A29:  rng <:q,an:> c= [:rng q, rng an:] by FUNCT_3:51;
      dom diffreal = [:REAL,REAL:] by FUNCT_2:def 1;
      then
A30:  [:rng q, rng an:] c= dom diffreal by ZFMISC_1:96;
      dom (diffreal.:(q,an)) = dom(diffreal*<:q,an:>) by FUNCOP_1:def 3
        .= dom <:q,an:> by A30,A29,RELAT_1:27,XBOOLE_1:1
        .= dom q /\ dom an by FUNCT_3:def 7;
      then
A31:  dom q0= dom q /\ dom an by RVSUM_1:def 6
        .= Seg m /\ Seg m by A5,A19,FINSEQ_1:def 3
        .= Seg m;
      then len q0=m by FINSEQ_1:def 3;
      then
A32:  q0 is Element of m-tuples_on REAL by FINSEQ_2:92;
A33:  now
        let j be Nat such that
A34:    j in dom q0;
        consider s be FinSequence of REAL such that
A35:    dom(s) = Seg (n+1) and
A36:    q.j=Sum(s) and
A37:    for i be Nat st i in dom(s) holds s.i=a.[i,j] by A5,A6,A31,A34;
        s.(n+1)=a.[n+1,j] by A35,A37,FINSEQ_1:4;
        then
A38:    s.(n+1)=an.j by A19,A21,A31,A34;
        reconsider sn=s|Seg (n) as FinSequence of REAL by FINSEQ_1:18;
        take sn;
        n+1 in NAT by ORDINAL1:def 12;
        then
A39:    len s = n+1 by A35,FINSEQ_1:def 3;
        then n <= len s by NAT_1:11;
        hence
A40:    dom sn =Seg n by FINSEQ_1:17;
        sn^<*(s.(n+1))*> = s by A39,FINSEQ_3:55;
        then q.j-an.j=Sum(sn) +an.j-an.j by A36,A38,RVSUM_1:74
          .=Sum(sn);
        hence q0.j = Sum(sn) by A34,VALUED_1:13;
        thus for i be Nat st i in dom(sn) holds sn.i=a0.[i,j]
        proof
          n <= n+1 by NAT_1:11;
          then
A41:      Seg n c= Seg (n+1) by FINSEQ_1:5;
          dom a= [:Seg (n+1),Seg m:] by FUNCT_2:def 1;
          then
A42:      dom a0 = [:Seg (n+1),Seg m:] /\ [:Seg n,Seg m:] by RELAT_1:61
            .= [:Seg n,Seg m:] by A41,ZFMISC_1:101;
          let i be Nat such that
A43:      i in dom(sn);
A44:      [i,j] in [:Seg n,Seg m:] by A31,A34,A40,A43,ZFMISC_1:87;
          thus sn.i=s.i by A43,FUNCT_1:47
            .=a.[i,j] by A35,A37,A40,A43,A41
            .=a0.[i,j] by A44,A42,FUNCT_1:47;
        end;
      end;
      len q=m by A5,FINSEQ_1:def 3;
      then q is Element of m-tuples_on REAL by FINSEQ_2:92;
      then
A45:  q0+an=q by A22,RVSUM_1:43;
        n+1 in NAT by ORDINAL1:def 12;
        then
      len p=n+1 by A3,FINSEQ_1:def 3;
      then p0^<*Sum(an)*> = p by A24,FINSEQ_3:55;
      hence Sum(p) = Sum(p0)+Sum(an) by RVSUM_1:74
        .=Sum(q0)+Sum(an) by A2,A10,A8,A31,A33
        .=Sum(q) by A32,A22,A45,RVSUM_1:89;
    end;
    hence thesis;
  end;
  now
    let m be Nat, a be Function of [: Seg 0, Seg m :],REAL;
    let p,q be FinSequence of REAL such that
A46: dom p=Seg 0 and
    for i be Nat st i in dom p holds ex r be FinSequence of REAL st (dom(r
    ) = Seg m & p.i=Sum(r) & for j be Nat st j in dom(r) holds r.j=a.[i,j]) and
A47: dom q=Seg m and
A48: for j be Nat st j in dom q holds ex s be FinSequence of REAL st (
dom(s) = Seg 0 & q.j=Sum(s) & for i be Nat st i in dom(s) holds s.i=a.[i,j] );
    reconsider m as Element of NAT by ORDINAL1:def 12;
    now
      let z be object;
      assume
A49:  z in dom q;
      then z in { k where k is Nat : 1 <= k & k <= m } by A47,FINSEQ_1:def 1;
      then ex k be Nat st z=k & 1 <= k & k <= m;
      then reconsider j=z as Nat;
      consider s be FinSequence of REAL such that
A50:  dom(s) = Seg 0 and
A51:  q.j=Sum(s) and
      for i be Nat st i in dom(s) holds s.i=a.[i,j] by A48,A49;
      s = <*>REAL by A50;
      hence q.z=0 by A51,RVSUM_1:72;
    end;
    then q = dom q --> 0 by FUNCOP_1:11;
    then
A52: q= m |-> 0 by A47,FINSEQ_2:def 2;
    p = <*>REAL by A46;
    hence Sum(p)=Sum(q) by A52,RVSUM_1:72,81;
  end;
  then
A53: P[0];
  thus for n be Nat holds P[n] from NAT_1:sch 2(A53,A1);
end;
