
theorem Th28:
  for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
f,g be PartFunc of X,ExtREAL st f is_simple_func_in S &
g is_simple_func_in S holds f+g is_simple_func_in S
proof
  let X be non empty set, S be SigmaField of X, M be sigma_Measure of S, f,g
  be PartFunc of X,ExtREAL such that
A1: f is_simple_func_in S and
A4: g is_simple_func_in S;
  g is real-valued by A4,MESFUNC2:def 4;
  then
A8: dom (f+g) = dom f /\ dom g by MESFUNC2:2;
  consider F be Finite_Sep_Sequence of S, a be FinSequence of ExtREAL such that
A10: F,a are_Re-presentation_of f by A1,MESFUNC3:12;
  consider G be Finite_Sep_Sequence of S, b be FinSequence of ExtREAL such that
A9: G,b are_Re-presentation_of g by A4,MESFUNC3:12;
  set la = len a;
  set lb = len b;
A11: dom F = dom a & dom G= dom b by A9,A10,MESFUNC3:def 1;
  deffunc FG1(Nat) = F.(($1-'1) div lb + 1) /\ G.(($1-'1) mod lb + 1);
  consider FG be FinSequence such that
A12: len FG = la*lb and
A13: for k be Nat st k in dom FG holds FG.k=FG1(k) from FINSEQ_1:sch 2;
A14: dom FG = Seg(la*lb) by A12,FINSEQ_1:def 3;
  now
    let k be Nat;
    assume k in dom FG; then
    FG.k = F.((k-'1) div lb + 1) /\ G.((k-'1) mod lb + 1) by A13;
    hence FG.k in S;
  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
A25: k in dom FG and
A26: l in dom FG and
A27: k <> l;
    set m=(l-'1) mod lb + 1;
    set n=(l-'1) div lb + 1;
    set j=(k-'1) mod lb + 1;
    set i=(k-'1) div lb + 1;
A29: FG.k = F.i /\ G.j by A13,A25;
A30: k in Seg (la*lb) by A12,A25,FINSEQ_1:def 3;
A31: 1 <= k & k <= la*lb & 1 <= l & l <= la*lb by A12,A25,A26,FINSEQ_3:25;
    then
A33: lb divides (la*lb) & 1 <= la*lb by NAT_D:def 3,XXREAL_0:2;
A34: lb <> 0 by A30;
    then lb >= 1 by NAT_1:14; then
A35: ((la*lb) -' 1) div lb = ((la*lb) div lb) - 1 by A33,NAT_2:15;
    (k -' 1) <= (la*lb -' 1) by A31,NAT_D:42;
    then (k -' 1) div lb <= (la*lb div lb) - 1 by A35,NAT_2:24;
    then i <= la*lb div lb by XREAL_1:19;
    then i <= la by A34,NAT_D:18; then
A37: i in dom F by A11,NAT_1:11,FINSEQ_3:25;
    m <= lb & j <= lb by A34,NAT_D:1,NAT_1:13; then
A42: m in dom G & j in dom G by A11,NAT_1:11,FINSEQ_3:25;
    (l -' 1) <= (la*lb -' 1) by A31,NAT_D:42;
    then (l -' 1) div lb <= (la*lb div lb) - 1 by A35,NAT_2:24;
    then n <= la*lb div lb by XREAL_1:19;
    then n <= la by A34,NAT_D:18; then
A44: n in dom F by A11,NAT_1:11,FINSEQ_3:25;
      (l-'1)+1=(n-1)*lb+(m-1)+1 by A34,NAT_D:2;
      then
A40:  l - 1 + 1 = (n-1)*lb+m by A31,XREAL_1:233;
      (k-'1)+1=(i-1)*lb+(j-1)+1 by A34,NAT_D:2; then
A41:  k - 1 + 1 = (i-1)*lb + j by A31,XREAL_1:233;
    per cases by A27,A40,A41;
    suppose
      i <> n; then
A45:  F.i misses F.n by A37,A44,MESFUNC3:4;
      FG.k /\ FG.l= (F.i /\ G.j) /\ (F.n /\ G.m) by A13,A26,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
        .= {} by A45;
      hence thesis;
    end;
    suppose
      j <> m; then
A46:  G.j misses G.m by A42,MESFUNC3:4;
      FG.k /\ FG.l= (F.i /\ G.j) /\ (F.n /\ G.m) by A13,A26,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
        .= {} by A46;
      hence thesis;
    end;
  end;
  then reconsider FG as Finite_Sep_Sequence of S by MESFUNC3:4;
A51: dom f = union rng F by A10,MESFUNC3:def 1;
A70: dom g = union rng G by A9,MESFUNC3:def 1;
A71: dom (f+g) = union rng FG
  proof
    thus dom (f+g) c= union rng FG
    proof
      let z be object;
      assume z in dom (f+g); then
A72:  z in dom f & z in dom g by A8,XBOOLE_0:def 4;
      then consider Y be set such that
A73:  z in Y and
A74:  Y in rng F by A51,TARSKI:def 4;
      consider Z be set such that
A75:  z in Z and
A76:  Z in rng G by A70,A72,TARSKI:def 4;
      consider j be object such that
A77:  j in dom G and
A78:  Z = G.j by A76,FUNCT_1:def 3;
      reconsider j as Element of NAT by A77;
      consider j9 being Nat such that
A81:  j = 1 + j9 by A77,Lm2,FINSEQ_3:25;
      consider i be object such that
A82:  i in dom F and
A83:  Y = F.i by A74,FUNCT_1:def 3;
      reconsider i as Element of NAT by A82;
      consider i9 being Nat such that
A85:  i = 1 + i9 by A82,Lm2,FINSEQ_3:25;
A80:  1 <= j & j <= lb by A11,A77,FINSEQ_3:25; then
A87:  j9 < lb by A81,NAT_1:13;
      reconsider k = (i-1)*lb+j as Nat by A85;
A88:  k >= 0 + j by A85,XREAL_1:6; then
A89:  k -' 1 = k - 1 by A80,XREAL_1:233,XXREAL_0:2
        .= i9*lb + j9 by A85,A81; then
A90:  i = (k-'1) div lb +1 by A85,A87,NAT_D:def 1;
      i <= la by A11,A82,FINSEQ_3:25;
      then i-1 <= la-1 by XREAL_1:9;
      then (i-1)*lb <= (la - 1)*lb by XREAL_1:64; then
A91:  k <= (la - 1) * lb + j by XREAL_1:6;
      (la - 1) * lb + j <= (la - 1) * lb + lb by A80,XREAL_1:6; then
A92:  k <= la*lb by A91,XXREAL_0:2;
B1:   k >= 1 by A80,A88,XXREAL_0:2; then
A93:  k in Seg (la*lb) by A92;
      k in dom FG by A12,B1,A92,FINSEQ_3:25; then
A94:  FG.k in rng FG by FUNCT_1:def 3;
A95:  j = (k-'1) mod lb +1 by A81,A89,A87,NAT_D:def 2;
      z in F.i /\ G.j by A73,A83,A75,A78,XBOOLE_0:def 4;
      then z in FG.k by A13,A14,A90,A95,A93;
      hence thesis by A94,TARSKI:def 4;
    end;
    let z be object;
    assume z in union rng FG;
    then consider Y be set such that
A96: z in Y and
A97: Y in rng FG by TARSKI:def 4;
    consider k be object such that
A98: k in dom FG and
A99: Y = FG.k by A97,FUNCT_1:def 3;
    reconsider k as Element of NAT by A98;
    set j=(k-'1) mod lb +1;
    set i=(k-'1) div lb +1;
    FG.k=F.i /\ G.j by A13,A98; then
A100: z in F.i & z in G.j by A96,A99,XBOOLE_0:def 4;
A102: 1 <= k & k <= la*lb by A12,A98,FINSEQ_3:25;
A103: lb <> 0 by A102; then
A104: lb >= 1 by NAT_1:14;
    lb divides (la*lb) & 1 <= la*lb by A102,NAT_D:def 3,XXREAL_0:2; then
A105: ((la*lb) -' 1) div lb = ((la*lb) div lb) - 1 by A104,NAT_2:15;
A106: la*lb div lb = la by A103,NAT_D:18;
    (k -' 1) <= (la*lb -' 1) by A102,NAT_D:42;
    then (k -' 1) div lb <= (la*lb div lb) - 1 by A105,NAT_2:24;
    then i <= la*lb div lb by XREAL_1:19;
    then i in dom F by A11,A106,NAT_1:11,FINSEQ_3:25;
    then F.i in rng F by FUNCT_1:def 3; then
a107: z in dom f by A51,A100,TARSKI:def 4;
    1 <= j <= lb by A103,NAT_D:1,NAT_1:11,13;
    then j in dom G by A11,FINSEQ_3:25;
    then G.j in rng G by FUNCT_1:def 3;
    then z in dom g by A70,A100,TARSKI:def 4;
    hence thesis by A8,a107,XBOOLE_0:def 4;
  end;
A107: 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+g).x = (f+g).y
  proof
    let k be Nat;
    let x,y be Element of X;
    assume that
A108: k in dom FG and
A109: x in FG.k & y in FG.k;
    set i=(k-'1) div lb + 1;
    set j=(k-'1) mod lb + 1;
A110: i >= 1 & j >= 1 by NAT_1:11;
    FG.k = F.i /\ G.j by A13,A108; then
A112: x in F.i & x in G.j & y in F.i & y in G.j by A109,XBOOLE_0:def 4;
A113: 1 <= k & k <= la*lb by A12,A108,FINSEQ_3:25; then
A115: (k -' 1) <= (la*lb -' 1) by NAT_D:42;
A116: lb divides (la*lb) & 1 <= la*lb by A113,NAT_D:def 3,XXREAL_0:2;
A117: lb <> 0 by A113;
    then lb >= 1 by NAT_1:14;
    then ((la*lb) -' 1) div lb = ((la*lb) div lb) - 1 by A116,NAT_2:15;
    then (k -' 1) div lb <= (la*lb div lb) - 1 by A115,NAT_2:24;
    then i <= la*lb div lb by XREAL_1:19;
    then i <= la by A117,NAT_D:18; then
A119: f.x=a.i & f.y = a.i by A10,A11,A110,A112,FINSEQ_3:25,MESFUNC3:def 1;
A120: j <= lb by A117,NAT_D:1,NAT_1:13;
    FG.k in rng FG by A108,FUNCT_1:def 3; then
A124: x in dom (f+g) & y in dom (f+g) by A71,A109,TARSKI:def 4;
    hence (f+g).x= f.x+g.x by MESFUNC1:def 3
      .= a.i+b.j by A9,A11,A110,A120,A112,A119,FINSEQ_3:25,MESFUNC3:def 1
      .= f.y+g.y by A9,A11,A110,A120,A112,A119,FINSEQ_3:25,MESFUNC3:def 1
      .= (f+g).y by A124,MESFUNC1:def 3;
  end;
  now
    let x be Element of X;
    assume
A188: x in dom (f+g);
    then |. (f+g).x .| = |. f.x + g.x .| by MESFUNC1:def 3; then
A189: |. (f+g).x .| <= |. f.x .| + |. g.x .| by EXTREAL1:24;
    x in dom f & x in dom g by A188,A8,XBOOLE_0:def 4; then
    |. f.x .| < +infty & |. g.x .| < +infty
      by A1,A4,MESFUNC2:def 1,def 4;
    then |. f.x .| + |. g.x .| <> +infty by XXREAL_3:16;
    hence |. (f+g).x .| < +infty by A189,XXREAL_0:2,4;
  end;
  hence f+g is_simple_func_in S by A71,A107,MESFUNC2:def 1,def 4;
end;
