reserve X for non empty set,
  Y for set,
  S for SigmaField of X,
  M for sigma_Measure of S,
  f,g for PartFunc of X,COMPLEX,
  r for Real,
  k for Real,
  n for Nat,
  E for Element of S;
reserve x,A for set;

theorem
  f is_simple_func_in S iff Re f is_simple_func_in S & Im f is_simple_func_in S
proof
  hereby
    assume f is_simple_func_in S;
    then consider F be Finite_Sep_Sequence of S such that
A1: dom f = union rng F and
A2: for n being Nat,x,y being Element of X st n in dom F & x in F.n &
    y in F.n holds f.x = f.y;
A3: dom Im f = union rng F by A1,COMSEQ_3:def 4;
A4: for n being Nat,x,y being Element of X st n in dom F & x in F.n & y
    in F.n holds (Im f).x = (Im f).y
    proof
      let n be Nat,x,y be Element of X;
      assume that
A5:   n in dom F and
A6:   x in F.n & y in F.n;
      F.n c= union rng F by A5,MESFUNC3:7;
      then (Im f).x = Im(f.x) & (Im f).y = Im(f.y) by A3,A6,COMSEQ_3:def 4;
      hence thesis by A2,A5,A6;
    end;
A7: dom Re f = union rng F by A1,COMSEQ_3:def 3;
    for n being Nat,x,y being Element of X st n in dom F & x in F.n & y in
    F.n holds (Re f).x = (Re f).y
    proof
      let n be Nat,x,y be Element of X;
      assume that
A8:   n in dom F and
A9:   x in F.n & y in F.n;
      F.n c= union rng F by A8,MESFUNC3:7;
      then (Re f).x = Re(f.x) & (Re f).y = Re(f.y) by A7,A9,COMSEQ_3:def 3;
      hence thesis by A2,A8,A9;
    end;
    hence Re f is_simple_func_in S & Im f is_simple_func_in S by A7,A3,A4,
MESFUNC6:def 2;
  end;
  assume that
A10: Re f is_simple_func_in S and
A11: Im f is_simple_func_in S;
  consider F be Finite_Sep_Sequence of S such that
A12: dom Re f = union rng F and
A13: for n being Nat,x,y being Element of X st n in dom F & x in F.n & y
  in F.n holds (Re f).x = (Re f).y by A10,MESFUNC6:def 2;
  set la = len F;
A14: dom f = union rng F by A12,COMSEQ_3:def 3;
  consider G be Finite_Sep_Sequence of S such that
A15: dom Im f = union rng G and
A16: for n being Nat,x,y being Element of X st n in dom G & x in G.n & y
  in G.n holds (Im f).x = (Im f).y by A11,MESFUNC6:def 2;
  set lb = len G;
  deffunc FG1(Nat) = F.(($1-'1) div lb + 1) /\ G.(($1-'1) mod lb + 1);
  consider FG be FinSequence such that
A17: len FG = la*lb and
A18: for k be Nat st k in dom FG holds FG.k=FG1(k) from FINSEQ_1:sch 2;
A19: dom FG = Seg(la*lb) by A17,FINSEQ_1:def 3;
  now
    let k be Nat;
A20: lb divides la*lb by NAT_D:def 3;
    set j=(k-'1) mod lb + 1;
    set i=(k-'1) div lb + 1;
    assume
A21: k in dom FG;
    then
A22: 1 <= k by FINSEQ_3:25;
    then
A23: lb > 0 by A17,A21,FINSEQ_3:25;
A24: k <= la*lb by A17,A21,FINSEQ_3:25;
    then k -' 1 <= la*lb -' 1 by NAT_D:42;
    then
A25: (k -' 1) div lb <= (la*lb -' 1) div lb by NAT_2:24;
A26: 1 <= la*lb by A22,A24,XXREAL_0:2;
    1 <= lb by A23,NAT_1:14;
    then (la*lb -' 1) div lb = la*lb div lb - 1 by A26,A20,NAT_2:15;
    then i <= la*lb div lb by A25,XREAL_1:19;
    then i >= 1 & i <= la by A23,NAT_1:14,NAT_D:18;
    then i in dom F by FINSEQ_3:25;
    then
A27: F.i in rng F by FUNCT_1:3;
    (k -' 1) mod lb < lb by A23,NAT_D:1;
    then j >= 1 & j <= lb by NAT_1:13,14;
    then j in dom G by FINSEQ_3:25;
    then G.j in rng G by FUNCT_1:3;
    then F.i /\ G.j in S by A27,MEASURE1:34;
    hence FG.k in S by A18,A21;
  end;
  then reconsider FG as FinSequence of S by FINSEQ_2:12;
  for k,l be Nat st k in dom FG & l in dom FG & k <> l holds FG.k misses FG.l
  proof
    let k,l be Nat;
    assume that
A28: k in dom FG and
A29: l in dom FG and
A30: k <> l;
    set m=(l-'1) mod lb + 1;
    set n=(l-'1) div lb + 1;
A31: 1 <= k by A28,FINSEQ_3:25;
    then
A32: lb > 0 by A17,A28,FINSEQ_3:25;
    then
A33: (l-'1)+1=(n-1)*lb+(m-1)+1 by NAT_D:2;
A34: k <= la*lb by A17,A28,FINSEQ_3:25;
    then
A35: lb divides la*lb & 1 <= la*lb by A31,NAT_1:14,NAT_D:def 3;
    1 <= lb by A32,NAT_1:14;
    then
A36: (la*lb -' 1) div lb = la*lb div lb - 1 by A35,NAT_2:15;
    set j=(k-'1) mod lb + 1;
    set i=(k-'1) div lb + 1;
    FG.k = F.i /\ G.j by A18,A28;
    then
A37: FG.k /\ FG.l= (F.i /\ G.j) /\ (F.n /\ G.m) by A18,A29
      .= F.i /\ (G.j /\ (F.n /\ G.m)) by XBOOLE_1:16
      .= F.i /\ (F.n /\ (G.j /\ G.m)) by XBOOLE_1:16
      .= (F.i /\ F.n) /\ (G.j /\ G.m) by XBOOLE_1:16;
    l <= la*lb by A17,A29,FINSEQ_3:25;
    then l -' 1 <= la*lb -' 1 by NAT_D:42;
    then (l -' 1) div lb <= la*lb div lb - 1 by A36,NAT_2:24;
    then (l -' 1) div lb + 1 <= la*lb div lb by XREAL_1:19;
    then n >= 1 & n <= la by A32,NAT_1:14,NAT_D:18;
    then n in Seg la;
    then
A38: n in dom F by FINSEQ_1:def 3;
    1 <= l by A29,FINSEQ_3:25;
    then
A39: l - 1 + 1 = (n-1)*lb+m by A33,XREAL_1:233;
    (l -' 1) mod lb < lb by A32,NAT_D:1;
    then m >= 1 & m <= lb by NAT_1:13,14;
    then m in Seg lb;
    then
A40: m in dom G by FINSEQ_1:def 3;
    k -' 1 <= la*lb -' 1 by A34,NAT_D:42;
    then (k -' 1) div lb <= la*lb div lb - 1 by A36,NAT_2:24;
    then (k -' 1) div lb + 1 <= la*lb div lb by XREAL_1:19;
    then i >= 1 & i <= la by A32,NAT_1:11,NAT_D:18;
    then i in Seg la;
    then
A41: i in dom F by FINSEQ_1:def 3;
    (k-'1)+1=(i-1)*lb+(j-1)+1 by A32,NAT_D:2;
    then
A42: k - 1 + 1 = (i-1)*lb + j by A31,XREAL_1:233;
    (k -' 1) mod lb < lb by A32,NAT_D:1;
    then j >= 1 & j <= lb by NAT_1:11,13;
    then j in Seg lb;
    then
A43: j in dom G by FINSEQ_1:def 3;
    per cases by A30,A42,A39;
    suppose
      i <> n;
      then F.i misses F.n by A41,A38,MESFUNC3:4;
      then FG.k /\ FG.l= {} /\ (G.j /\ G.m) by A37;
      hence thesis;
    end;
    suppose
      j <> m;
      then G.j misses G.m by A43,A40,MESFUNC3:4;
      then FG.k /\ FG.l= (F.i /\ F.n) /\ {} by A37;
      hence thesis;
    end;
  end;
  then reconsider FG as Finite_Sep_Sequence of S by MESFUNC3:4;
A44: dom f = union rng G by A15,COMSEQ_3:def 4;
A45: dom f = union rng FG
  proof
    thus dom f c= union rng FG
    proof
      let z be object;
      assume
A46:  z in dom f;
      then consider Y be set such that
A47:  z in Y and
A48:  Y in rng F by A14,TARSKI:def 4;
      consider Z be set such that
A49:  z in Z and
A50:  Z in rng G by A44,A46,TARSKI:def 4;
      consider j be Nat such that
A51:  j in dom G and
A52:  Z = G.j by A50,FINSEQ_2:10;
      consider i be Nat such that
A53:  i in dom F and
A54:  F.i = Y by A48,FINSEQ_2:10;
      1 <= i by A53,FINSEQ_3:25;
      then consider i9 being Nat such that
A55:  i = 1 + (i9 qua Complex) by NAT_1:10;
      set k=(i-1)*lb+j;
      reconsider k as Nat by A55;
      i <= la by A53,FINSEQ_3:25;
      then i-1 <= la-1 by XREAL_1:9;
      then (i-1)*lb <= (la - 1)*lb by XREAL_1:64;
      then
A56:  k <= (la - 1) * lb + j by XREAL_1:6;
A57:  j <= lb by A51,FINSEQ_3:25;
      then (la - 1) * lb + j <= (la - 1) * lb + lb by XREAL_1:6;
      then
A58:  k <= la*lb by A56,XXREAL_0:2;
A59:  1 <= j by A51,FINSEQ_3:25;
      then consider j9 being Nat such that
A60:  j = 1 + (j9 qua Complex) by NAT_1:10;
A61:  j9 < lb by A57,A60,NAT_1:13;
A62:  k >= j by A55,NAT_1:11;
      then
A63:  k -' 1 = k - 1 by A59,XREAL_1:233,XXREAL_0:2
        .= i9*lb + j9 by A55,A60;
      then
A64:  i = (k-'1) div lb +1 by A55,A61,NAT_D:def 1;
A65:  k >= 1 by A59,A62,XXREAL_0:2;
      then
A66:  k in Seg (la*lb) by A58;
A67:  j = (k-'1) mod lb +1 by A60,A63,A61,NAT_D:def 2;
      k in dom FG by A17,A65,A58,FINSEQ_3:25;
      then
A68:  FG.k in rng FG by FUNCT_1:def 3;
      z in F.i /\ G.j by A47,A54,A49,A52,XBOOLE_0:def 4;
      then z in FG.k by A18,A19,A64,A67,A66;
      hence thesis by A68,TARSKI:def 4;
    end;
    let z be object;
    assume z in union rng FG;
    then consider Y be set such that
A69: z in Y and
A70: Y in rng FG by TARSKI:def 4;
    consider k be Nat such that
A71: k in dom FG and
A72: FG.k = Y by A70,FINSEQ_2:10;
A73: 1 <= k by A71,FINSEQ_3:25;
    then
A74: lb > 0 by A17,A71,FINSEQ_3:25;
    then
A75: 1 <= lb by NAT_1:14;
A76: k <= la*lb by A17,A71,FINSEQ_3:25;
    then lb divides (la*lb) & 1 <= la*lb by A73,NAT_1:14,NAT_D:def 3;
    then
A77: (la*lb -' 1) div lb = la*lb div lb - 1 by A75,NAT_2:15;
    set j=(k-'1) mod lb +1;
    set i=(k-'1) div lb +1;
    k -' 1 <= la*lb -' 1 by A76,NAT_D:42;
    then (k -' 1) div lb <= la*lb div lb - 1 by A77,NAT_2:24;
    then
A78: i >= 1 & i <= la*lb div lb by NAT_1:14,XREAL_1:19;
    la*lb div lb = la by A74,NAT_D:18;
    then i in dom F by A78,FINSEQ_3:25;
    then
A79: F.i in rng F by FUNCT_1:def 3;
    FG.k=F.i /\ G.j by A18,A71;
    then z in F.i by A69,A72,XBOOLE_0:def 4;
    hence thesis by A14,A79,TARSKI:def 4;
  end;
  for k being Nat,x,y being Element of X st k in dom FG & x in FG.k & y
  in FG.k holds f.x = f.y
  proof
    let k be Nat;
    let x,y be Element of X;
    set i=(k-'1) div lb + 1;
    set j=(k-'1) mod lb + 1;
    assume that
A80: k in dom FG and
A81: x in FG.k & y in FG.k;
A82: FG.k c= union rng FG by A80,MESFUNC3:7;
    then FG.k c= dom Im f by A45,COMSEQ_3:def 4;
    then
A83: (Im f).x = Im(f.x) & (Im f).y = Im(f.y) by A81,COMSEQ_3:def 4;
A84: 1 <= k by A80,FINSEQ_3:25;
    then
A85: lb > 0 by A17,A80,FINSEQ_3:25;
    then (k -' 1) mod lb < lb by NAT_D:1;
    then j >= 1 & j <= lb by NAT_1:13,14;
    then
A86: j in dom G by FINSEQ_3:25;
    FG.k c= dom Re f by A45,A82,COMSEQ_3:def 3;
    then
A87: (Re f).x = Re(f.x) & (Re f).y = Re(f.y) by A81,COMSEQ_3:def 3;
A88: k <= la*lb by A17,A80,FINSEQ_3:25;
    then
A89: k -' 1 <= la*lb -' 1 by NAT_D:42;
A90: FG.k = F.( (k-'1) div lb + 1 ) /\ G.( (k-'1) mod lb + 1 ) by A18,A80;
    then x in G.j & y in G.j by A81,XBOOLE_0:def 4;
    then
A91: Im(f.x) = Im(f.y) by A16,A86,A83;
A92: lb divides (la*lb) & 1 <= la*lb by A84,A88,NAT_1:14,NAT_D:def 3;
    1 <= lb by A85,NAT_1:14;
    then ((la*lb) -' 1) div lb = la*lb div lb - 1 by A92,NAT_2:15;
    then (k -' 1) div lb <= la*lb div lb - 1 by A89,NAT_2:24;
    then i <= la*lb div lb by XREAL_1:19;
    then i >= 1 & i <= la by A85,NAT_1:14,NAT_D:18;
    then
A93: i in dom F by FINSEQ_3:25;
    x in F.i & y in F.i by A81,A90,XBOOLE_0:def 4;
    then Re(f.x) = Re(f.y) by A13,A93,A87;
    hence thesis by A91;
  end;
  hence thesis by A45;
end;
