
theorem Th19:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
  f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S
 st f is A-measurable & A = dom f & E is non-descending & lim E c= A
 & M.(A \ lim E) = 0
  & (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty)
holds
 ex I be ExtREAL_sequence st
 (for n be Nat holds I.n = Integral(M,f|((Partial_Union E).n)))
 & I is convergent & Integral(M,f) = lim I
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
     f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S;
    assume that
A1:  f is A-measurable and
A2:  A = dom f and
A3:  E is non-descending and
A4:  lim E c= A and
A5:  M.(A \ lim E) = 0 and
A6:  (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty);

    Union E is Element of S by PROB_1:17; then
    reconsider LE = lim E as Element of S by A3,SETLIM_1:80;

    A \ (A \ LE) = A /\ LE by XBOOLE_1:48 .= LE by A4,XBOOLE_1:28; then
A7:Integral(M,f) = Integral(M,f|LE) by A1,A2,A5,MESFUNC5:95;

    reconsider F = Partial_Diff_Union E as SetSequence of S;

    set g = f|LE;
A8:LE = dom f /\ LE by A2,A4,XBOOLE_1:28;
    f is LE-measurable by A1,A4,MESFUNC1:30; then
A9: g is LE-measurable by A8,MESFUNC5:42;

A10:lim E = Union E by A3,SETLIM_1:80; then
A11: LE = Union F by PROB_3:20;

A12: max+f is nonnegative & max-f is nonnegative by MESFUN11:5;

A13: max+f|A = max+(f|A) & max-f|A = max-(f|A) &
    max+f|LE = max+g & max-f|LE = max-g by MESFUNC5:28;

    dom(max+f) = dom f & dom(max-f) = dom f by MESFUNC2:def 2,def 3; then
    integral+(M,max+f|LE) <= integral+(M,max+f|A)
  & integral+(M,max-f|LE) <= integral+(M,max-f|A)
    by A2,A4,A12,A1,MESFUNC2:25,26,MESFUNC5:83; then
A14: integral+(M,max+g) < +infty or integral+(M,max-g) <+infty
      by A2,A6,A13,XXREAL_0:2;

A15: LE = dom g by A8,RELAT_1:61; then
    consider J be ExtREAL_sequence such that
A16:  for n be Nat holds J.n = Integral(M,g|(F.n)) and
A17:  J is summable & Integral(M,g) = Sum J by A9,A11,A14,Th17;
    reconsider I = Partial_Sums J as ExtREAL_sequence;
    take I;
A18: for n be Nat holds g|((Partial_Union F).n) = f|((Partial_Union E).n)
    proof
     let n be Nat;
A19:  (Partial_Union F).n = (Partial_Union E).n by PROB_3:19;

     now let x be object;
      assume x in (Partial_Union E).n; then
      consider k be Nat such that
A20:    k <= n & x in E.k by PROB_3:13;
      k in NAT by ORDINAL1:def 12; then
      k in dom E by FUNCT_2:def 1; then
      E.k c= union rng E by FUNCT_1:3,ZFMISC_1:74; then
      E.k c= Union E by CARD_3:def 4;
      hence x in Union E by A20;
     end; then
     (Partial_Union E).n c= LE by A10;
     hence thesis by A19,RELAT_1:74;
    end;

A21: for n be Nat holds (Partial_Union E).n c= Union E
    proof
     let n be Nat;
     now let x be object;
      assume x in (Partial_Union E).n; then
      consider k be Nat such that
A22:    k <= n & x in E.k by PROB_3:13;
      k in NAT by ORDINAL1:def 12; then
      k in dom E by FUNCT_2:def 1; then
      E.k in rng E by FUNCT_1:3; then
      x in union rng E by A22,TARSKI:def 4;
      hence x in Union E by CARD_3:def 4;
     end;
     hence thesis;
    end;

    defpred P[Nat] means I.$1 = Integral(M,g|((Partial_Union F).$1));

    I.0 = J.0 by MESFUNC9:def 1 .= Integral(M,g|(F.0)) by A16; then
A23: P[0] by PROB_3:def 2;
A24: for n be Nat st P[n] holds P[n+1]
    proof
     let n be Nat;
     assume A25: P[n];
     reconsider PFn = (Partial_Union F).n as Element of S by PROB_1:25;
     reconsider Fn1 = F.(n+1) as Element of S by PROB_1:25;

     n < n+1 by NAT_1:13; then
A26:  PFn misses Fn1 by PROB_3:42;

     PFn \/ Fn1 = (Partial_Union F).(n+1) by PROB_3:def 2; then
A27: PFn \/ Fn1 = (Partial_Union E).(n+1) by PROB_3:19; then
A28:  PFn \/ Fn1 c= dom g by A21,A15,A10;

A29:  g is (PFn \/ Fn1)-measurable by A9,A21,A10,A27,MESFUNC1:30;

A30:  max+g is nonnegative & max-g is nonnegative by MESFUN11:5;
A31: max+g is LE-measurable & max-g is LE-measurable by A9,A15,MESFUNC2:25,26;
A32: max+g|LE = max+(g|LE) & max-g|LE = max-(g|LE) by MESFUNC5:28;

     dom(max+g) = dom g & dom(max-g) = dom g by MESFUNC2:def 2,def 3; then
     integral+(M,max+g|(PFn \/ Fn1)) <= integral+(M,max+g|LE)
   & integral+(M,max-g|(PFn \/ Fn1)) <= integral+(M,max-g|LE)
       by A30,A31,A15,A27,A21,A10,MESFUNC5:83; then
     integral+(M,max+g|(PFn \/ Fn1)) < +infty
  or integral+(M,max-g|(PFn \/ Fn1)) < +infty by A14,A32,XXREAL_0:2; then
A33: integral+(M,max+(g|(PFn \/ Fn1))) < +infty
  or integral+(M,max-(g|(PFn \/ Fn1))) < +infty by MESFUNC5:28;

     I.(n+1) = (Partial_Sums J).n + J.(n+1) by MESFUNC9:def 1
      .= Integral(M,g|PFn) + Integral(M,g|Fn1) by A16,A25
      .= Integral(M,g|(PFn \/ Fn1)) by A28,A29,A26,A33,Th18;
     hence I.(n+1) = Integral(M,g|((Partial_Union F).(n+1))) by PROB_3:def 2;
    end;
A34: for n be Nat holds P[n] from NAT_1:sch 2(A23,A24);
    thus for n be Nat holds I.n = Integral(M,f|((Partial_Union E).n))
    proof
     let n be Nat;
     I.n = Integral(M,g|((Partial_Union F).n)) by A34;
     hence thesis by A18;
    end;
    thus I is convergent by A17,MESFUNC9:def 2;
    thus Integral(M,f) = lim I by A7,A17,MESFUNC9:def 3;
end;
