
theorem Th66:
for X1,X2 be non empty set, S1 be SigmaField of X1, S2 be SigmaField of X2,
 E be Element of sigma measurable_rectangles(S1,S2)
 st E in Field_generated_by measurable_rectangles(S1,S2)
 ex f be disjoint_valued FinSequence of measurable_rectangles(S1,S2),
    A be FinSequence of S1, B be FinSequence of S2 st
     len f = len A & len f = len B & E = Union f
   & (for n be Nat st n in dom f holds proj1(f.n) = A.n & proj2(f.n) = B.n)
   & (for n be Nat, x,y be set st n in dom f & x in X1 & y in X2 holds
         chi(f.n,[:X1,X2:]).(x,y) = chi(A.n,X1).x * chi(B.n,X2).y)
proof
   let X1,X2 be non empty set, S1 be SigmaField of X1, S2 be SigmaField of X2,
   E be Element of sigma measurable_rectangles(S1,S2);
   assume E in Field_generated_by measurable_rectangles(S1,S2); then
   E in DisUnion measurable_rectangles(S1,S2) by SRINGS_3:22; then
   E in {E1 where E1 is Subset of [:X1,X2:] :
    ex f be disjoint_valued FinSequence of measurable_rectangles(S1,S2)
      st E1 = Union f} by SRINGS_3:def 3; then
   consider E1 be Subset of [:X1,X2:] such that
A1: E = E1
  & ex f be disjoint_valued FinSequence of measurable_rectangles(S1,S2)
      st E1 = Union f;
   consider f be disjoint_valued FinSequence of measurable_rectangles(S1,S2)
    such that
A2: E1 = Union f by A1;

   defpred P1[Nat,object] means $2 = proj1(f.$1);

A3:for i be Nat st i in Seg len f ex Ai being Element of S1 st P1[i,Ai]
   proof
    let i be Nat;
    assume i in Seg len f; then
    i in dom f by FINSEQ_1:def 3; then
    f.i in measurable_rectangles(S1,S2) by PARTFUN1:4; then
    f.i in the set of all [:A,B:] where A is Element of S1, B is Element of S2
      by MEASUR10:def 5; then
    consider Ai be Element of S1, Bi be Element of S2 such that
A4:  f.i = [:Ai,Bi:];
    per cases;
    suppose A5: Bi <> {};
     take Ai;
     thus proj1(f.i) = Ai by A4,A5,FUNCT_5:9;
    end;
    suppose A6: Bi = {};
     reconsider Ai = {} as Element of S1 by MEASURE1:7;
     take Ai;
     thus proj1(f.i) = Ai by A4,A6;
    end;
   end;
   consider A being FinSequence of S1 such that
A7: dom A = Seg len f
  & for i be Nat st i in Seg len f holds P1[i,A.i] from FINSEQ_1:sch 5(A3);

   defpred P2[Nat,object] means $2 = proj2(f.$1);

A8:for i be Nat st i in Seg len f ex Bi being Element of S2 st P2[i,Bi]
   proof
    let i be Nat;
    assume i in Seg len f; then
    i in dom f by FINSEQ_1:def 3; then
    f.i in measurable_rectangles(S1,S2) by PARTFUN1:4; then
    f.i in the set of all [:A,B:] where A is Element of S1, B is Element of S2
      by MEASUR10:def 5; then
    consider Ai be Element of S1, Bi be Element of S2 such that
A9:  f.i = [:Ai,Bi:];
    per cases;
    suppose A10: Ai <> {};
     take Bi;
     thus proj2(f.i) = Bi by A9,A10,FUNCT_5:9;
    end;
    suppose A11: Ai = {};
     reconsider Bi = {} as Element of S2 by MEASURE1:7;
     take Bi;
     thus proj2(f.i) = Bi by A9,A11;
    end;
   end;
   consider B being FinSequence of S2 such that
A12:dom B = Seg len f
  & for i be Nat st i in Seg len f holds P2[i,B.i] from FINSEQ_1:sch 5(A8);
   take f,A,B;
   thus len f = len A by A7,FINSEQ_1:def 3;
   thus len f = len B by A12,FINSEQ_1:def 3;
   thus E = Union f by A1,A2;
   thus
A13:for n be Nat st n in dom f holds proj1(f.n) = A.n & proj2(f.n) = B.n
   proof
    let n be Nat;
    assume n in dom f; then
    n in Seg len f by FINSEQ_1:def 3;
    hence A.n = proj1(f.n) & B.n = proj2(f.n) by A7,A12;
   end;
    let n be Nat, x,y be set;
    assume A14: n in dom f & x in X1 & y in X2; then
A15:A.n = proj1(f.n) & B.n = proj2(f.n) by A13;
    f.n in measurable_rectangles(S1,S2) by A14,PARTFUN1:4; then
    f.n in the set of all [:A,B:] where A is Element of S1, B is Element of S2
       by MEASUR10:def 5; then
    consider An be Element of S1, Bn be Element of S2 such that
A16: f.n = [:An,Bn:];
A17:[x,y] in [:X1,X2:] by A14,ZFMISC_1:87;
    per cases;
    suppose f.n = {}; then
     chi(f.n,[:X1,X2:]).(x,y) = 0
   & chi(A.n,X1).x = 0 & chi(B.n,X2).y = 0 by A14,A15,A17,FUNCT_3:def 3;
     hence chi(f.n,[:X1,X2:]).(x,y) = chi(A.n,X1).x * chi(B.n,X2).y;
    end;
    suppose f.n <> {}; then
A18: A.n = An & B.n = Bn by A15,A16,FUNCT_5:9;
     per cases;
     suppose A19: x in A.n & y in B.n; then
      chi(A.n,X1).x = 1 & chi(B.n,X2).y = 1 by FUNCT_3:def 3; then
A20:  chi(A.n,X1).x * chi(B.n,X2).y = 1 by XXREAL_3:81;
      proj1(f.n) c= An & proj2(f.n) c= Bn by A16,FUNCT_5:10; then
      [x,y] in f.n & [x,y] in [:X1,X2:] by A19,A15,A16,ZFMISC_1:def 2;
      hence chi(f.n,[:X1,X2:]).(x,y) = chi(A.n,X1).x * chi(B.n,X2).y
        by A20,FUNCT_3:def 3;
     end;
     suppose A21: not x in A.n or not y in B.n; then
      chi(A.n,X1).x = 0 or chi(B.n,X2).y = 0 by A14,FUNCT_3:def 3; then
A22:  chi(A.n,X1).x * chi(B.n,X2).y = 0;
      not [x,y] in f.n by A18,A21,A16,ZFMISC_1:87;
      hence chi(f.n,[:X1,X2:]).(x,y) = chi(A.n,X1).x * chi(B.n,X2).y
        by A17,A22,FUNCT_3:def 3;
     end;
    end;
end;
