
theorem Th9:
  for p,q be FinSequence of REAL
  st len p <= len q
   & for i be Nat st i in dom q holds
       (i <= len p implies q.i = p.i)
     & (len p < i implies q.i = 0)
  holds Sum q = Sum p
  proof
    let p,q be FinSequence of REAL;
    assume that
    A1: len p <= len q and
    A2: for i be Nat st i in dom q holds
          (i <= len p implies q.i = p.i)
        & (len p < i implies q.i = 0);
    len q - len p is Nat by A1,NAT_1:21; then
    consider ix be Nat such that
    A3: ix = len q - len p;
    set x = ix |-> (0 qua Real);
    A5: Sum x = 0 by RVSUM_1:81;
    q = p ^ x
    proof
      A6: len x = ix by Th4; then
      A7: len q = len p + len x by A3;
      A8: dom q = Seg(len p + len x) by A3,A6,FINSEQ_1:def 3;
      A9: for i be Nat st i in dom p holds q.i = p.i
      proof
        let i be Nat;
        assume i in dom p; then
        A10: 1 <= i <= len p by FINSEQ_3:25; then
        1 <= i <= len q by A1,XXREAL_0:2; then
        i in dom q by FINSEQ_3:25;
        hence thesis by A2,A10;
      end;
      for i be Nat st i in dom x holds q.(len p + i) = x.i
      proof
        let i be Nat;
        assume i in dom x; then
        A11: i in Seg ix by FUNCOP_1:13; then
        A12: x.i = 0 by FINSEQ_2:57;
        consider j be Nat such that
        A13: j = len p + i;
        A14: i >= 1 by A11,FINSEQ_1:1; then
        A15: len p < j by A13,NAT_1:19;
        A16: 0+1 <= j by A13,A14,INT_1:7;
        i <= len x by A6,A11,FINSEQ_1:1; then
        j <= len q by A7,A13,XREAL_1:6; then
        j in dom q by A16,FINSEQ_3:25;
        hence thesis by A2,A12,A13,A15;
      end;
      hence thesis by A8,A9,FINSEQ_1:def 7;
    end; then
    Sum q = Sum p + Sum x by RVSUM_1:75
         .= Sum p by A5;
    hence thesis;
  end;
