
theorem
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 E be Element of S, f be PartFunc of X,ExtREAL
 st E c= dom f & f is nonpositive & f is E-measurable
 holds
  ex F be Functional_Sequence of X,ExtREAL st
   F is additive
 & (for n be Nat holds
      F.n is_simple_func_in S & F.n is nonpositive & F.n is E-measurable)
 & (for x be Element of X st x in E holds
      F#x is summable & f.x = Sum(F#x))
 & ex I be ExtREAL_sequence st
     (for n be Nat holds I.n = Integral(M,(F.n)|E))
   & I is summable
   & Integral(M,f|E) = Sum I
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    E be Element of S, f be PartFunc of X,ExtREAL;
    assume that
A1:  E c= dom f and
A2:  f is nonpositive and
A3:  f is E-measurable;
    set g = -f;
A4: E c= dom g by A1,MESFUNC1:def 7; then
    consider G be Functional_Sequence of X,ExtREAL such that
A5:  G is additive
   & (for n be Nat holds
        G.n is_simple_func_in S & G.n is nonnegative & G.n is E-measurable)
   & (for x be Element of X st x in E holds
        G#x is summable & g.x = Sum(G#x))
   & ex J be ExtREAL_sequence st
       (for n be Nat holds J.n = Integral(M,(G.n)|E))
     & J is summable
     & Integral(M,g|E) = Sum J by A1,A2,A3,MESFUNC9:48,MEASUR11:63;
    take F = -G;
    thus F is additive by A5,Th41;
    thus for n be Nat holds
        F.n is_simple_func_in S & F.n is nonpositive & F.n is E-measurable
    proof
     let n be Nat;
     (-1)(#)(G.n) is_simple_func_in S by A5,MESFUNC5:39; then
     -(G.n) is_simple_func_in S by MESFUNC2:9;
     hence
A6:   F.n is_simple_func_in S by Th37;
     G.n is nonnegative by A5; then
     -(G.n) is nonpositive;
     hence F.n is nonpositive by Th37;
     thus F.n is E-measurable by A6,MESFUNC2:34;
    end;
    thus for x be Element of X st x in E holds F#x is summable & f.x = Sum(F#x)
    proof
     let x be Element of X;
     assume A7: x in E; then
A8:  G#x is summable & g.x = Sum(G#x) by A5;
     hence F#x is summable by Th48;
     g.x = -(f.x) by A7,A4,MESFUNC1:def 7; then
     f.x = - Sum(G#x) by A8;
     hence f.x = Sum((F#x)) by A8,Th48;
    end;
    thus ex I be ExtREAL_sequence st
       (for n be Nat holds I.n = Integral(M,(F.n)|E))
     & I is summable
     & Integral(M,f|E) = Sum I
    proof
     consider J be ExtREAL_sequence such that
A9:   (for n be Nat holds J.n = Integral(M,(G.n)|E))
    & J is summable
    & Integral(M,g|E) = Sum J by A5;
     take I = -J;
     thus for n be Nat holds I.n = Integral(M,(F.n)|E)
     proof
      let n be Nat;
      dom I = NAT by FUNCT_2:def 1; then
A10:  n in dom I by ORDINAL1:def 12;
A11:  J.n = Integral(M,(G.n)|E) by A9;
      F.n = -(G.n) by Th37; then
A12:  (F.n)|E = -((G.n)|E) by Th3;
A13:  G.n is_simple_func_in S by A5; then
      consider GG be Finite_Sep_Sequence of S such that
A14:   dom(G.n) = union rng GG &
       for k be Nat,x,y be Element of X st k in dom GG & x in GG.k & y in GG.k
         holds (G.n).x = (G.n).y by MESFUNC2:def 4;
      reconsider V = union rng GG as Element of S by MESFUNC2:31;
      reconsider VE = V /\ E as Element of S;
A15:  VE = dom((G.n)|E) by A14,RELAT_1:61;
      (G.n)|E is VE-measurable by A13,MESFUNC2:34,MESFUNC5:34; then
      Integral(M,(F.n)|E) = -Integral(M,(G.n)|E) by A12,A15,Th52;
      hence I.n = Integral(M,(F.n)|E) by A10,A11,MESFUNC1:def 7;
     end;
     thus I is summable by A9,Th45;
A16: Partial_Sums J is convergent by A9,MESFUNC9:def 2;
A17: Sum I = lim Partial_Sums I by MESFUNC9:def 3
      .= lim (-(Partial_Sums J)) by Th44
      .= -(lim Partial_Sums J) by A16,DBLSEQ_3:17
      .= - Integral(M,g|E) by A9,MESFUNC9:def 3;
A18: dom(f|E) = E by A1,RELAT_1:62;
A19: E = dom f /\ E by A1,XBOOLE_1:28;
     g|E = -(f|E) by Th3; then
     Integral(M,g|E) = - Integral(M,f|E) by A3,A18,A19,Th52,MESFUNC5:42;
     hence Integral(M,f|E) = Sum I by A17;
    end;
end;
