
theorem Th30:
  for X1,X2 being non empty set,
      S1 being SigmaField of X1,
      S2 being SigmaField of X2,
      M2 being sigma_Measure of S2,
      D being Function of NAT,S1, E being Function of NAT,S2,
      A being Element of S1, B being Element of S2,
      F being Functional_Sequence of X2,ExtREAL,
      RD being sequence of Funcs(X1,REAL),
     x being Element of X1 st
   (for n being Nat holds RD.n = chi(D.n,X1))
   & (for n being Nat holds F.n = ((RD.n).x)(#)(chi(E.n,X2)))
   & (for n being Nat holds E.n c= B)
   holds
     ex I be ExtREAL_sequence st
     (for n be Nat holds I.n = M2.(E.n) * (chi(D.n,X1).x)) &
     I is summable & Integral(M2,lim Partial_Sums F) = Sum I
proof
   let X1,X2 be non empty set, S1 being SigmaField of X1,
       S2 be SigmaField of X2, M2 be sigma_Measure of S2,
       D be Function of NAT,S1, E be Function of NAT,S2,
       A be Element of S1, B be Element of S2,
       F be Functional_Sequence of X2,ExtREAL,
       RD be sequence of Funcs(X1,REAL),
       x be Element of X1;
   assume that
A7: (for n being Nat holds RD.n = chi(D.n,X1)) and
A8: (for n being Nat holds F.n = ((RD.n).x)(#)(chi(E.n,X2))) and
A9: (for n being Nat holds E.n c= B);
B1:for n be Nat holds dom(F.n) = X2
   proof
    let n be Nat;
    dom(F.n) = dom( ((RD.n).x)(#)(chi(E.n,X2)) ) by A8; then
    dom(F.n) = dom(chi(E.n,X2)) by MESFUNC1:def 6;
    hence dom(F.n) = X2 by FUNCT_3:def 3;
   end;
   reconsider SX2 = X2 as Element of S2 by PROB_1:5;
P1:dom(F.0) = X2 by B1;
B2:for n be Nat, y be set st y in E.n holds (F.n).y = 0 or (F.n).y = 1
   proof
    let n be Nat, y be set;
    assume B3: y in E.n;
B4: E.n in S2; then
    y in X2 by B3; then
B5: y in dom(F.n) by B1; then
B6: (F.n).y in rng(F.n) by FUNCT_1:3;
    reconsider y1=y as Element of X2 by B3,B4;
B7: now assume x in D.n; then
     chi(D.n,X1).x = 1 by FUNCT_3:def 3; then
     (RD.n).x = 1 by A7; then
     F.n = 1(#)(chi(E.n,X2)) by A8; then
     F.n = chi(E.n,X2) by MESFUNC2:1; then
     rng(F.n) c= {0,1} by FUNCT_3:39;
     hence (F.n).y = 0 or (F.n).y = 1 by B6,TARSKI:def 2;
    end;
    now assume not x in D.n; then
     chi(D.n,X1).x = 0 by FUNCT_3:def 3; then
     (RD.n).x = 0 by A7; then
     F.n = ( 0(#)(chi(E.n,X2)) ) by A8; then
     (F.n).y = 0 * chi(E.n,X2).y1 by B5,MESFUNC1:def 6;
     hence (F.n).y = 0;
    end;
    hence (F.n).y =0 or (F.n).y = 1 by B7;
   end;
B8:for n be Nat, y be set st not y in E.n holds (F.n).y = 0
   proof
    let n be Nat, y be set;
    assume B9: not y in E.n;
B10:now assume B11: y in X2; then
     reconsider y1=y as Element of X2;
B12: chi(E.n,X2).y1 = 0 by B9,FUNCT_3:def 3;
B13: y in dom(F.n) by B1,B11;
     (F.n) = ((RD.n).x)(#)(chi(E.n,X2)) by A8; then
     (F.n).y = (RD.n).x * (chi(E.n,X2)).y1 by B13,MESFUNC1:def 6;
     hence (F.n).y = 0 by B12;
    end;
    now assume not y in X2; then
     not y in dom(F.n);
     hence (F.n).y = 0 by FUNCT_1:def 2;
    end;
    hence (F.n).y = 0 by B10;
   end;
P2:now let n,m be Nat;
    assume n <> m;
    thus for y be set st y in dom(F.n) /\ dom(F.m) holds
      (F.n).y <> +infty or (F.m).y <> -infty
    proof
     let y be set;
     assume y in dom(F.n) /\ dom(F.m);
     y in E.n implies (F.n).y <> +infty or (F.m).y <> -infty by B2;
     hence (F.n).y <> +infty or (F.m).y <> -infty by B8;
    end;
   end; then
S2:F is additive by MESFUNC9:def 5;
   now let n,m be Nat;
    dom(F.n) = X2 & dom(F.m) = X2 by B1;
    hence dom(F.n) = dom(F.m);
   end; then
P3:F is with_the_same_dom by MESFUNC8:def 2;
P4:for n be Nat holds F.n is nonnegative & F.n is B-measurable
   proof
    let n be Nat;
    now let y be object;
     per cases;
     suppose not y in dom(F.n);
      hence (F.n).y >= 0 by FUNCT_1:def 2;
     end;
     suppose y in dom(F.n) & y in E.n;
      hence (F.n).y >= 0 by B2;
     end;
     suppose y in dom(F.n) & not y in E.n;
      hence (F.n).y >= 0 by B8;
     end;
    end;
    hence F.n is nonnegative by SUPINF_2:51;
    thus F.n is B-measurable
    proof
B14: dom(chi(E.n,X2)) = X2 by FUNCT_3:def 3;
     per cases;
     suppose x in D.n; then
      chi(D.n,X1).x = 1 by FUNCT_3:def 3; then
      (RD.n).x = 1 by A7; then
      F.n = 1 (#) (chi(E.n,X2)) by A8;
      hence F.n is B-measurable by B14,MESFUNC1:37,MESFUNC2:29;
     end;
     suppose not x in D.n; then
      chi(D.n,X1).x = 0 by FUNCT_3:def 3; then
      (RD.n).x = 0 by A7; then
      F.n = 0 (#) (chi(E.n,X2)) by A8;
      hence F.n is B-measurable by B14,MESFUNC1:37,MESFUNC2:29;
     end;
    end;
   end;
   for y be Element of X2 st y in B holds F#y is summable
   proof
    let y be Element of X2;
    assume y in B;
    for n be Element of NAT holds 0 <= (F#y).n
    proof
     let n be Element of NAT;
     (F#y).n = (F.n).y by MESFUNC5:def 13;
     hence 0 <= (F#y).n by P4,SUPINF_2:51;
    end; then
    F#y is nonnegative by SUPINF_2:39; then
    Partial_Sums (F#y) is non-decreasing by MESFUNC9:16;
    hence F#y is summable by RINFSUP2:37,MESFUNC9:def 2;
   end; then
   consider I be ExtREAL_sequence such that
Q1: (for n be Nat holds I.n = Integral(M2,(F.n)|B))
   & I is summable & Integral(M2,(lim(Partial_Sums F))|B) = Sum I
       by P1,P2,P3,P4,MESFUNC9:def 5,51;
   take I;
R1:for n be Nat holds chi(E.n,X2) is SX2-measurable by MESFUNC2:29;
Q2:for n be Nat holds I.n = M2.(E.n) * chi(D.n,X1).x
   proof
    let n be Nat;
B16:I.n = Integral(M2,(F.n)|B) by Q1;
B17:dom((F.n)|B) = dom(F.n) /\ B by RELAT_1:61; then
B18:dom((F.n)|B) = X2 /\ B by B1;
B19:dom((RD.n).x(#)(chi(E.n,X2)|B)) = dom(chi(E.n,X2)|B) by MESFUNC1:def 6
     .= dom(chi(E.n,X2)) /\ B by RELAT_1:61
     .= X2 /\ B by FUNCT_3:def 3;
    now let y be object;
     assume B20: y in dom((F.n)|B); then
     reconsider y1=y as Element of X2;
B22: y in X2 & y in B by B17,B20,XBOOLE_0:def 4;
     dom(chi(E.n,X2)) = X2 by FUNCT_3:def 3; then
B23: y in dom(((RD.n).x)(#)(chi(E.n,X2))) by B22,MESFUNC1:def 6;
B21: ((F.n)|B).y = (F.n).y1 by B20,FUNCT_1:47
      .= (((RD.n).x)(#)(chi(E.n,X2))).y1 by A8
      .= ((RD.n).x) * (chi(E.n,X2).y) by B23,MESFUNC1:def 6;
     ( (RD.n).x (#) (chi(E.n,X2)|B) ).y
       = ((RD.n).x) * (chi(E.n,X2)|B).y by B20,B18,B19,MESFUNC1:def 6
      .= ((RD.n).x) * (chi(E.n,X2).y) by B22,FUNCT_1:49;
      hence ((F.n)|B).y = ( (RD.n).x (#) (chi(E.n,X2)|B) ).y by B21;
    end; then
B24:I.n = Integral(M2,(RD.n).x(#)(chi(E.n,X2)|B))
       by B16,B18,B19,FUNCT_1:def 11;
C0: B = dom( (RD.n).x (#) (chi(E.n,X2)|B) ) by B19,XBOOLE_1:28;
C4: dom(chi(E.n,X2)|B) = dom(chi(E.n,X2)) /\ B by RELAT_1:61;
    dom(chi(E.n,X2)) /\ B = X2 /\ B by FUNCT_3:def 3; then
C3: dom(chi(E.n,X2)) /\ B = B by XBOOLE_1:28; then
C8: chi(E.n,X2)|B is B-measurable by MESFUNC2:29,MESFUNC5:42;
C5a: chi(E.n,X2)|B is nonnegative by MESFUNC5:15;
C6: now assume x in D.n; then
     chi(D.n,X1).x = 1 by FUNCT_3:def 3;
     hence (RD.n).x = 1 by A7;
    end;
C7: now assume not x in D.n; then
     chi(D.n,X1).x = 0 by FUNCT_3:def 3;
     hence (RD.n).x = 0 by A7;
    end; then
    (RD.n).x (#) (chi(E.n,X2)|B) is nonnegative by C5a,C6,MESFUNC5:20; then
    I.n = integral+(M2,(RD.n).x(#)(chi(E.n,X2)|B))
      by B24,C0,C8,C3,C4,MESFUNC1:37,MESFUNC5:88;
    then
    I.n = (RD.n).x * integral+(M2,(chi(E.n,X2)|B))
      by C3,C4,C6,C7,C8,MESFUNC5:15,86; then
D2: I.n = (RD.n).x * Integral(M2,(chi(E.n,X2)|B))
      by C3,C4,C8,MESFUNC5:15,88;
E1: dom(chi(E.n,X2)) = X2 by FUNCT_3:def 3;
    for y being object st y in dom(chi(E.n,X2)) \ B holds chi(E.n,X2).y = 0
    proof
     let y be object;
     assume E4: y in dom(chi(E.n,X2)) \ B; then
     reconsider y1=y as Element of X2;
     E.n c= B by A9; then
     not y1 in E.n by E4,XBOOLE_0:def 5;
     hence chi(E.n,X2).y = 0 by FUNCT_3:def 3;
    end; then
    Integral(M2,chi(E.n,X2)) = Integral(M2,chi(E.n,X2)|B)
      by E1,R1,Th28; then
    I.n = M2.(E.n) * (RD.n).x by D2,MESFUNC9:14;
    hence I.n = M2.(E.n) * (chi(D.n,X1).x) by A7;
   end;
F1:dom(lim Partial_Sums F) = dom((Partial_Sums F).0) by MESFUNC8:def 9
    .= dom(F.0) by MESFUNC9:def 4; then
F4:dom(lim Partial_Sums F) = SX2 by B1;
G0:Partial_Sums F is with_the_same_dom Functional_Sequence of X2,ExtREAL
     by P2,P3,MESFUNC9:def 5,43;
G1:dom((Partial_Sums F).0) = dom(F.0) by MESFUNC9:def 4 .= SX2 by B1;
R2:for n be Nat holds F.n is SX2-measurable
   proof
    let n be Nat;
    chi(E.n,X2) is SX2-measurable & dom(chi(E.n,X2)) = SX2
       by MESFUNC2:29,FUNCT_3:def 3; then
    ((RD.n).x)(#)(chi(E.n,X2)) is SX2-measurable by MESFUNC1:37;
    hence F.n is SX2-measurable by A8;
   end;
   for n be Nat holds F.n is without-infty
   proof
    let n be Nat;
    F.n is nonnegative by P4;
    hence F.n is without-infty;
   end; then
G2:for n be Nat holds (Partial_Sums F).n is SX2-measurable
     by R2,MESFUNC9:41;
   for y be Element of X2 st y in SX2 holds
    (Partial_Sums F)#y is convergent
   proof
    let y be Element of X2;
    assume y in SX2; then
    y in dom(F.0) by B1;
    hence (Partial_Sums F)#y is convergent by P3,P4,MESFUNC9:38;
   end; then
F2: (lim Partial_Sums F) is SX2-measurable by G0,G1,G2,MESFUNC8:25;
F3:for y being object st y in dom(lim Partial_Sums F) \ B
     holds (lim Partial_Sums F).y = 0
   proof
    let y be object;
    assume K0: y in dom(lim Partial_Sums F) \ B; then
K1: y in dom(lim Partial_Sums F) & not y in B by XBOOLE_0:def 5; then
    y in dom((Partial_Sums F).0) by MESFUNC8:def 9; then
J1: y in dom(F.0) by MESFUNC9:def 4;
    reconsider y1 = y as Element of X2 by K0;
K2: (lim Partial_Sums F).y = lim((Partial_Sums F)#y1)
      by K1,MESFUNC8:def 9;
    for n be Nat holds ((Partial_Sums F)#y1).n = 0
    proof
     let n be Nat;
K6:  ((Partial_Sums F)#y1).n = ((Partial_Sums F).n).y1 by MESFUNC5:def 13;
     defpred P[Nat] means ((Partial_Sums F).$1).y1 = 0;
K3:  ((Partial_Sums F).0).y1 = (F.0).y1 by MESFUNC9:def 4;
     E.0 c= B by A9; then
K4:  P[0] by K1,K3,B8;
K5:  for k be Nat st P[k] holds P[k+1]
     proof
      let k be Nat;
      assume J2: P[k];
J3:   dom((Partial_Sums F).(k+1)) = dom((Partial_Sums F).0)
        by S2,P3,MESFUNC9:43,MESFUNC8:def 2
        .= dom(F.0) by MESFUNC9:def 4;
J4:   E.(k+1) c= B by A9;
      (Partial_Sums F).(k+1) = (Partial_Sums F).k + F.(k+1)
         by MESFUNC9:def 4; then
      ((Partial_Sums F).(k+1)).y1
        = ((Partial_Sums F).k).y1 + (F.(k+1)).y1 by J1,J3,MESFUNC1:def 3
       .= (F.(k+1)).y1 by J2,XXREAL_3:4;
      hence P[k+1] by J4,B8,K1;
     end;
     for k be Nat holds P[k] from NAT_1:sch 2(K4,K5);
     hence ((Partial_Sums F)#y1).n = 0 by K6;
    end;
    hence (lim Partial_Sums F).y = 0 by K2,MESFUNC5:52;
   end;
   for y be object st y in dom(lim Partial_Sums F) holds
    (lim Partial_Sums F).y >= 0
   proof
    let y be object;
    assume L1: y in dom(lim Partial_Sums F); then
    reconsider y1=y as Element of X2;
L2: for n be Nat holds ((Partial_Sums F)#y1).n >= 0
    proof
     let n be Nat;
     ((Partial_Sums F).n).y1 >= 0 by P4,MESFUNC9:36,SUPINF_2:51;
     hence ((Partial_Sums F)#y1).n >= 0 by MESFUNC5:def 13;
    end;
    lim((Partial_Sums F)#y1) >= 0 by L1,F1,L2,P3,P4,MESFUNC9:10,38;
    hence (lim Partial_Sums F).y >= 0 by L1,MESFUNC8:def 9;
   end;
   hence thesis by Q1,Q2,F4,F2,F3,Th28,SUPINF_2:52;
end;
