 reserve X for set;
 reserve S for Subset-Family of X;

theorem
  for X1,X2 be set, S1 be semiring_of_sets of X1,S2 be semiring_of_sets of X2
  holds {s where s is Subset of [:X1,X2:]: ex x1,x2 be set st x1 in S1 &
  x2 in S2 & s=[:x1,x2:]} is semiring_of_sets of [:X1,X2:]
  proof
    let X1,X2 be set;
    let S1 be semiring_of_sets of X1;
    let S2 be semiring_of_sets of X2;
    defpred Q[object,object] means
    ex A,B being set st A = $2`1 & B = $2`2 & $1 = [:A,B:];
    set Y={s where s is Subset of [:X1,X2:]: ex
    x1,x2 be set st x1 in S1 & x2 in S2 & s=[:x1,x2:]};
A1: Y is with_empty_element
    proof
A2:   {} in S1 & {} in S2 by SETFAM_1:def 8;
      [:{},{}:] c= [:X1,X2:];
      then {} in Y by A2;
      hence thesis;
    end; then
A3: Y is non empty;
    reconsider Y as Subset-Family of [:X1,X2:] by Lem3;
A4: Y is cap-finite-partition-closed
    proof
      let D1,D2 be Element of Y;
      D1 in Y by A3;
      then consider s1 be Subset of [:X1,X2:] such that
A5:   D1=s1 & ex x11,x12 be set st x11 in S1 & x12 in S2 & s1=[:x11,x12:];
      consider x11,x12 be set such that
A6:   x11 in S1 & x12 in S2 & D1=[:x11,x12:] by A5;
      D2 in Y by A3;
      then consider s2 be Subset of [:X1,X2:] such that
A9:   D2=s2 &
      ex x21,x22 be set st x21 in S1 & x22 in S2 &s2=[:x21,x22:];
      consider x21,x22 be set such that
A10:  x21 in S1 & x22 in S2 &D2=[:x21,x22:] by A9;
      assume D1/\D2 is non empty;
      then [:x11/\x21,x12/\x22:]<>{} by ZFMISC_1:100,A6,A10;
      then
A13:  x11/\x21 is non empty & x12/\x22 is non empty;
      then consider y1 be finite Subset of S1 such that
A14:  y1 is a_partition of x11/\x21 by A6,A10,SRINGS_1:def 1;
      consider y2 be finite Subset of S2 such that
A15:  y2 is a_partition of x12/\x22 by A6,A10,A13,SRINGS_1:def 1;
      set YY= the set of all [:a,b:] where a is Element of y1,
      b is Element of y2;
A16:  y1 is non empty by A13,A14;
A17:  y2 is non empty by A13,A15;
A18:  YY c= Y
        proof
          let x be object;
          assume x in YY;
          then consider a0 be Element of y1, b0 be Element of y2 such that
A19:      x=[:a0,b0:];
          reconsider x as set by TARSKI:1;
A20:      a0 in S1
          proof
            a0 in y1 by A16;
            hence thesis;
          end;
A21:      b0 in S2
          proof
            b0 in y2 by A17;
            hence thesis;
          end;
          x is Subset of [:X1,X2:]
          proof
            x c= [:X1,X2:]
            proof
              let y be object;
              assume y in x;
              then consider ya0,yb0 be object such that
A22:          ya0 in a0 & yb0 in b0 & y=[ya0,yb0] by A19,ZFMISC_1:def 2;
              thus thesis by A20,A21,A22,ZFMISC_1:def 2;
            end;
            hence thesis;
          end;
          hence thesis by A19,A20,A21;
      end;
      set YY= the set of all [:a,b:] where a is Element of y1,
      b is Element of y2;
      YY is a_partition of [:x11/\x21,x12/\x22:] by A13,A14,A15,PUA2MSS1:8;
      then
A24:  YY is a_partition of D1/\D2 by A6,A10,ZFMISC_1:100;
      YY is finite
      proof
A25:    for x be object st x in YY holds
        ex y be object st y in [:y1,y2:] & Q[x,y]
        proof
          let x be object;
          assume x in YY;
          then consider x1 be Element of y1, x2 be Element of y2 such that
A26:      x=[:x1,x2:];
          set y=[x1,x2];
          reconsider Y1 = y`1, Y2 = y`2 as set;
A27:      x = [:Y1,Y2:] by A26;
          y in [:y1,y2:] by ZFMISC_1:def 2,A13,A14,A15;
          hence thesis by A27;
        end;
        consider f be Function such that
A28:    dom f=YY & rng f c= [:y1,y2:] and
A29:    for x being object st x in YY holds Q[x,f.x]
        from FUNCT_1:sch 6(A25);
        f is one-to-one
        proof
          let a,b be object;
          assume that
A30:      a in dom f and
A31:      b in dom f and
A32:      f.a=f.b;
          Q[a,f.a] & Q[b,f.a] by A29,A32,A28,A30,A31;
          hence thesis;
        end;
        then card YY c= card [:y1,y2:] by A28,CARD_1:10;
        hence thesis;
      end;
      hence thesis by A18,A24;
    end;
    Y is diff-finite-partition-closed
    proof
      let D3,D4 be Element of Y;
      D3 in Y by A3;
      then consider s1 be Subset of [:X1,X2:] such that
A34:  D3=s1 &
      ex x11,x12 be set st x11 in S1 & x12 in S2 & s1=[:x11,x12:];
      consider x11,x12 be set such that
A35:  x11 in S1 and
A36:  x12 in S2 and
A37:  D3=[:x11,x12:] by A34;
      D4 in Y by A3;
      then consider s2 be Subset of [:X1,X2:] such that
A40:  D4=s2 & ex x21,x22 be set st x21 in S1 & x22 in S2 & s2=[:x21,x22:];
      consider x21,x22 be set such that
A41:  x21 in S1 and
A42:  x22 in S2 and
A43:  D4=[:x21,x22:] by A40;
      assume D3\D4 is non empty;
A46:  (x11\x21 is non empty & x12 <>{}) implies
      ex Z1 be finite Subset of Y st Z1 is a_partition of [:x11\x21,x12:]
      proof
        assume
A47:    x11\x21 is non empty & x12<>{};
        then consider z1 be finite Subset of S1 such that
A48:    z1 is a_partition of x11\x21 by A35,A41,SRINGS_1:def 2;
A49:    z1 is non empty by A48,A47;
        set Z1=the set of all [:u1,x12:] where u1 is Element of z1;
A50:    Z1 is Subset of Y
        proof
          for x be object st x in Z1 holds x in Y
          proof
            let x be object;
            assume x in Z1;
            then consider a0 be Element of z1 such that
A51:        x=[:a0,x12:];
A52:        a0 in S1
            proof
              a0 in z1 by SUBSET_1:def 1,A47,A48;
              hence thesis;
            end;
            reconsider x as set by TARSKI:1;
            x is Subset of [:X1,X2:]
            proof
              for y be object st y in x holds y in [:X1,X2:]
              proof
                let y be object;
                assume y in x;
                then consider ya0,yx12 be object such that
A53:            ya0 in a0 & yx12 in x12 & y=[ya0,yx12] by A51,ZFMISC_1:def 2;
                thus thesis by A36,A52,A53,ZFMISC_1:def 2;
              end;
              hence thesis by TARSKI:def 3;
            end;
            hence thesis by A51,A52,A36;
          end;
          hence thesis by TARSKI:def 3;
        end;
A56:    Z1 is finite
        proof
          defpred P[object,object] means
          ex A being set st A = $2 & $1 = [:A,x12:];
A57:      for x be object st x in Z1 ex y be object st y in z1 & P[x,y]
          proof
            let x be object;
            assume x in Z1;
            then consider x1 be Element of z1 such that
A58:        x=[:x1,x12:];
            take x1;
            thus thesis by A49,A58;
          end;
          consider f be Function such that
A59:      dom f=Z1 & rng f c= z1 and
A60:      for x being object st x in Z1 holds
          P[x,f.x] from FUNCT_1:sch 6(A57);
          f is one-to-one
          proof
            let a,b be object;
            assume that
A61:        a in dom f and
A62:        b in dom f and
A63:        f.a=f.b;
            P[a,f.a] & P[b,f.b] by A59,A60,A61,A62;
            hence thesis by A63;
          end;
          then card Z1 c= card z1 by A59,CARD_1:10;
          hence thesis;
        end;
        Z1 is a_partition of [:x11\x21,x12:]
        proof
          set Z2=the set of all [:p,q:] where p is Element of z1,
          q is Element of {x12};
A65:      Z1=Z2
          proof
A66:      Z1 c= Z2
            proof
              let x be object;
              assume x in Z1;
              then consider x00 be Element of z1 such that
A67:          x=[:x00,x12:];
              x12 is Element of {x12} by TARSKI:def 1;
              hence thesis by A67;
            end;
            Z2 c= Z1
            proof
              let x be object;
              assume x in Z2;
              then consider x01 be Element of z1,x02 be Element of {x12}
              such that
A68:          x=[:x01,x02:];
              x=[:x01,x12:] by A68,TARSKI:def 1;
              hence thesis;
            end;
            hence thesis by A66;
          end;
          {x12} is a_partition of x12 by A47,EQREL_1:39;
          hence thesis by A65,PUA2MSS1:8,A47,A48;
        end;
        hence thesis by A50,A56;
      end;
A71:  (x11/\x21 <>{} & x12\x22 <>{}) implies
      ex Z2 be finite Subset of Y st Z2 is a_partition of [:x11/\x21,x12\x22:]
      proof
        assume
A72:    x11/\x21<>{} & x12\x22<>{};
        then consider z1 be finite Subset of S1 such that
A73:    z1 is a_partition of x11/\x21 by A35,A41,SRINGS_1:def 1;
        consider z2 be finite Subset of S2 such that
A74:    z2 is a_partition of x12\x22 by A72,A36,A42,SRINGS_1:def 2;
A75:    z2 is non empty by A72,A74;
        set Z2=the set of all [:u1,u2:] where u1 is Element of z1,
        u2 is Element of z2;
A76:    Z2 is Subset of Y
        proof
          for x be object st x in Z2 holds x in Y
          proof
            let x be object;
            assume x in Z2;
            then consider a0 be Element of z1, b0 be Element of z2 such that
A77:        x=[:a0,b0:];
            reconsider x as set by TARSKI:1;
A78:        a0 in S1
            proof
              a0 in z1 by SUBSET_1:def 1,A72,A73;
              hence thesis;
            end;
A79:        b0 in S2
            proof
              b0 in z2 by A75;
              hence thesis;
            end;
            x is Subset of [:X1,X2:]
            proof
              for y be object st y in x holds y in [:X1,X2:]
              proof
                let y be object;
                assume y in x;
                then consider ya0,yb0 be object such that
A80:            ya0 in a0 & yb0 in b0 & y=[ya0,yb0] by A77,ZFMISC_1:def 2;
                thus thesis by A78,A79,A80,ZFMISC_1:def 2;
              end;
              hence thesis by TARSKI:def 3;
            end;
            hence thesis by A77,A78,A79;
          end;
          hence thesis by TARSKI:def 3;
        end;
A83:    Z2 is finite
        proof
A84:      for x be object st x in Z2 holds
          ex y be object st y in [:z1,z2:] & Q[x,y]
          proof
            let x be object;
            assume x in Z2;
            then consider x1 be Element of z1, x2 be Element of z2 such that
A85:        x=[:x1,x2:];
            set y=[x1,x2];
            reconsider Y1 = y`1, Y2 = y`2 as set;
A86:        x=[:Y1,Y2:] by A85;
            y in [:z1,z2:] by A74,A73,A72,ZFMISC_1:def 2;
            hence thesis by A86;
          end;
          consider f be Function such that
A87:      dom f=Z2 & rng f c= [:z1,z2:] and
A88:      for x being object st x in Z2 holds
          Q[x,f.x] from FUNCT_1:sch 6(A84);
          f is one-to-one
          proof
            let a,b be object;
            assume that
A89:        a in dom f and
A90:        b in dom f and
A91:        f.a=f.b;
            reconsider Y1 = (f.a)`1, Y2 = (f.a)`2 as set by TARSKI:1;
            Q[a,f.a] & Q[b,f.b] by A87,A88,A89,A90;
            hence thesis by A91;
          end;
          then card Z2 c= card [:z1,z2:] by A87,CARD_1:10;
          hence thesis;
        end;
        Z2 is a_partition of [:x11/\x21,x12\x22:] by PUA2MSS1:8,A73,A74,A72;
        hence thesis by A76,A83;
      end;
A94:  ([:x11\x21,x12:]<>{} & [:x11/\x21,x12\x22:]={}) implies
      ex ZZ be set st ZZ is a_partition of [:x11,x12:]\[:x21,x22:] &
      ZZ is finite Subset of Y
      proof
        assume
A95:    ([:x11\x21,x12:]<>{} & [:x11/\x21,x12\x22:]={});
        then consider ZZ be finite Subset of Y such that
A96:    ZZ is a_partition of [:x11\x21,x12:] by A46;
        [:x11,x12:]\[:x21,x22:]=
        [:x11\x21,x12:]\/[:x11/\x21,x12\x22:] by Lem4;
        hence thesis by A95,A96;
      end;
A97:  ([:x11\x21,x12:]={}) & ([:x11/\x21,x12\x22:]<>{}) implies
      ex ZZ be set st ZZ is a_partition of [:x11,x12:]\[:x21,x22:] &
      ZZ is finite Subset of Y
      proof
        assume
A98:    ([:x11\x21,x12:]={}) & ([:x11/\x21,x12\x22:]<>{});
        then consider ZZ be finite Subset of Y such that
A99:    ZZ is a_partition of [:x11/\x21,x12\x22:] by A71;
        [:x11,x12:]\[:x21,x22:]=
        [:x11\x21,x12:]\/[:x11/\x21,x12\x22:] by Lem4;
        hence thesis by A98,A99;
      end;
A100: ([:x11\x21,x12:]={}) &
      ([:x11/\x21,x12\x22:]={}) implies ex ZZ be set
      st ZZ is a_partition of
      [:x11,x12:]\[:x21,x22:] & ZZ is finite Subset of Y
      proof
        assume
A101:   ([:x11\x21,x12:]={}) & ([:x11/\x21,x12\x22:]={});
        take {};
        [:x11,x12:]\[:x21,x22:]=
        [:x11\x21,x12:]\/[:x11/\x21,x12\x22:] by Lem4;
        hence thesis by A101,EQREL_1:45,SUBSET_1:1;
      end;
      [:x11\x21,x12:]<>{} & [:x11/\x21,x12\x22:]<>{}implies
      ex ZZ be set st ZZ is a_partition of [:x11,x12:]\[:x21,x22:] &
      ZZ is finite Subset of Y
      proof
        assume
A104:   ([:x11\x21,x12:]<>{}) & ([:x11/\x21,x12\x22:]<>{});
        then consider p1 be finite Subset of Y such that
A105:   p1 is a_partition of [:x11\x21,x12:] by A46;
        consider p2 be finite Subset of Y such that
A106:   p2 is a_partition of [:x11/\x21,x12\x22:] by A71,A104;
        [:x11,x12:]\[:x21,x22:]=[:x11\x21,x12:]\/[:x11/\x21,x12\x22:] &
        [:x11\x21,x12:] misses [:x11/\x21,x12\x22:] by Lem4;
        then
A107:   p1\/p2 is a_partition of [:x11,x12:]\[:x21,x22:]
        by A105,A106,DILWORTH:3;
        thus thesis by A107;
      end;
      hence thesis by A37,A43,A94,A97,A100;
    end;
    hence thesis by A1,A4;
  end;
