reserve k,n,m,l,p for Nat;
reserve n0,m0 for non zero Nat;
reserve f for FinSequence;
reserve x,X,Y for set;
reserve f1,f2,f3 for FinSequence of REAL;

theorem Th11:
  f2 = f1*Sgm(X) & dom f1 \ f1"{0} c= X & X c= dom f1 implies Sum f1 = Sum f2
proof
  assume
A1: f2 = f1*Sgm(X);
  set Y = dom f1 \ X;
  assume
A2: dom f1 \ f1"{0} c= X;
  assume
A3: X c= dom f1;
  per cases;
  suppose
A4: Y = {};
    X \ dom f1 = {} by A3,XBOOLE_1:37;
    then X = dom f1 by A4,XBOOLE_1:32;
    then X = Seg len f1 by FINSEQ_1:def 3;
    then Sgm X = idseq len f1 by FINSEQ_3:48;
    hence thesis by A1,FINSEQ_2:54;
  end;
  suppose
A5: Y <> {};
    set f3 = f1*Sgm(Y);
A6: Y c= dom f1 by XBOOLE_1:36;
A7: rng Sgm Y = Y by FINSEQ_1:def 14;
    then reconsider f3 as FinSequence of REAL by A6,Th9;
A8: X misses Y by XBOOLE_1:79;
A9: Y c= f1"{0}
    proof
      assume not Y c= f1"{0};
      then consider x be object such that
A10:  x in Y and
A11:  not x in f1"{0};
      x in dom f1 by A10,XBOOLE_0:def 5;
      then x in dom f1 \ f1"{0} by A11,XBOOLE_0:def 5;
      then x in X /\ Y by A2,A10,XBOOLE_0:def 4;
      hence contradiction by A8,XBOOLE_0:def 7;
    end;
    for y being object holds y in rng f3 iff y = 0
    proof
      let y be object;
      consider x be object such that
A12:  x in Y by A5,XBOOLE_0:def 1;
      hereby
        assume y in rng f3;
        then consider x be object such that
A13:    x in dom f3 and
A14:    y = f3.x by FUNCT_1:def 3;
A15:    x in dom Sgm Y by A13,FUNCT_1:11;
        then (Sgm Y).x in rng Sgm Y by FUNCT_1:3;
        then (Sgm Y).x in Y by FINSEQ_1:def 14;
        then f1.((Sgm Y).x) in {0} by A9,FUNCT_1:def 7;
        then f3.x in {0} by A15,FUNCT_1:13;
        hence y = 0 by A14,TARSKI:def 1;
      end;
      assume
A16:  y = 0;
      x in rng Sgm Y by A7,A12;
      then consider x9 be object such that
A17:  x9 in dom Sgm Y and
A18:  x = (Sgm Y).x9 by FUNCT_1:def 3;
      f1.x in {0} by A9,A12,FUNCT_1:def 7;
      then f1.((Sgm Y).x9) = y by A16,A18,TARSKI:def 1;
      then
A19:  f3.x9 = y by A17,FUNCT_1:13;
      x in dom f1 by A9,A12,FUNCT_1:def 7;
      then x9 in dom f3 by A17,A18,FUNCT_1:11;
      hence y in rng f3 by A19,FUNCT_1:def 3;
    end;
    then dom f3 = Seg len f3 & rng f3 = {0} by FINSEQ_1:def 3,TARSKI:def 1;
    then f3 = (Seg len f3) --> 0 by FUNCOP_1:9;
    then
A20: f3 = (len f3) |-> 0 by FINSEQ_2:def 2;
    then reconsider f3 as FinSequence of NAT;
    X \/ Y = dom f1 by A3,XBOOLE_1:45;
    then
A21: Sum f1 = Sum f2 + Sum f3 by A1,Th10,XBOOLE_1:79;
    Sum f3 = 0 by A20,BAGORDER:4;
    hence Sum f1 = Sum f2 by A21;
  end;
end;
