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

theorem Thm4:
  for S be cap-finite-partition-closed diff-c=-finite-partition-closed
  Subset-Family of X,SM be Function of NATPLUS,S holds
  ex P be countable Subset of S st P is a_partition of Union SM &
  for n be NatPlus holds Union (SM|Seg n)= union{s where s is Element of S:
  s in P & s c= Union (SM|Seg n)}
  proof
    let S be cap-finite-partition-closed diff-c=-finite-partition-closed
    Subset-Family of X;
    let SM be Function of NATPLUS,S;
    per cases;
    suppose
A1:   S ={};
      then
A2:   Union SM ={} by ZFMISC_1:2;
      set P={};
A3:   P is finite Subset of S & P is a_partition of {}
      by SUBSET_1:1,EQREL_1:45;
      for n be NatPlus holds Union (SM|Seg n)= union{s where s is Element of S:
      s in P & s c= Union (SM|Seg n)}
      proof
        let n be NatPlus;
        thus Union (SM|Seg n) c= union{s where s is Element of S:
        s in P & s c= Union (SM|Seg n)}
        proof
          let x be object;
          assume x in Union (SM|Seg n);
          hence thesis by A1,ZFMISC_1:2;
        end;
        thus union{s where s is Element of S: s in P &
        s c= Union (SM|Seg n)} c= Union (SM|Seg n)
        proof
          let x be object;
          assume x in union{s where s is Element of S: s in P &
          s c= Union (SM|Seg n)};
          then consider y be set such that
A5:       x in y and
A6:       y in {s where s is Element of S: s in P & s c= Union (SM|Seg n)}
          by TARSKI:def 4;
          consider s0 be Element of S such that
A7:       y=s0 and
          s0 in P and
A8:       s0 c= Union (SM|Seg n) by A6;
          thus thesis by A5,A7,A8;
        end;
      end;
      hence thesis by A2,A3;
    end;
    suppose
A9:   not S = {};
      then
A10:  dom SM = NATPLUS by FUNCT_2:def 1;
A11:  for x be NatPlus ex x1 be Nat st x1=x-1 &
      ex Px be finite Subset of S st
      Px is a_partition of SM.x\Union (SM|Seg x1)
      proof
        let x be NatPlus;
        set x1=x-1;
        reconsider x1 as Nat by CHORD:1;
        rng (SM|(Seg x1)) is finite Subset of S;
        then ex P be finite Subset of S
        st P is a_partition of SM.x\Union (SM|Seg x1) by Thm1;
        hence thesis;
      end;
      defpred FH[object,object] means
      ex x,xp be Nat st $1=x & xp=x-1 &
      $2 is finite Subset of S &
      $2 is a_partition of (SM.x)\Union (SM|Seg xp);
A12:  for n be object st n in NATPLUS
      ex y be object st y in bool S & FH[n,y]
      proof
        let n be object;
        assume n in NATPLUS;
        then consider n1 be NatPlus such that
A13:    n=n1;
        reconsider n as NatPlus by A13;
        consider x1 be Nat such that
A14:    x1=n-1 & ex Px be finite Subset of S st
        Px is a_partition of SM.n\Union (SM|Seg x1) by A11;
        thus thesis by A14;
      end;
      consider fi be Function such that
A15:  dom fi=NATPLUS & rng fi c= bool S and
A16:  for n be object st n in NATPLUS holds FH[n,fi.n] from FUNCT_1:sch 6(A12);
A17:  Union fi is countable Subset of S &
      Union fi is a_partition of Union SM
      proof
A18:    Union fi is countable Subset of S
        proof
A19:      Union fi is countable
          proof
            for v be set st v in dom fi holds fi.v is countable
            proof
              let v be set;
              assume v in dom fi;
              then FH[v,fi.v] by A15,A16;
              hence thesis;
            end;
            hence thesis by A15,CARD_4:11;
          end;
          Union fi c= S
          proof
            let u be object;
            assume u in Union fi;
            then ex v be set st u in v & v in rng fi by TARSKI:def 4;
            hence thesis by A15;
          end;
          hence thesis by A19;
        end;
A21:    Union fi is a_partition of Union SM
        proof
A22:      Union fi c= bool Union SM
          proof
            let w be object;
            assume w in Union fi;
            then consider w0 be set such that
A23:        w in w0 & w0 in rng fi by TARSKI:def 4;
            consider v0 be object such that
A24:        v0 in dom fi & w0=fi.v0 by A23,FUNCT_1:def 3;
            reconsider w as set by TARSKI:1;
            w c= union (rng SM)
            proof
              let v be object;
              assume
A25:          v in w;
              consider mx,mxp be Nat such that
A26:          v0=mx & mxp=mx-1 &
              fi.v0 is finite Subset of S &
              fi.v0 is a_partition of (SM.mx)\Union (SM|Seg mxp)
              by A15,A16,A24;
A27:          v in (SM.mx)\Union (SM|Seg mxp) by A23,A24,A25,A26;
              mx in dom SM by A9,A15,A24,A26,FUNCT_2:def 1;
              then SM.mx in rng SM by FUNCT_1:def 3;
              hence thesis by A27,TARSKI:def 4;
            end;
            hence thesis;
          end;
A28:      union Union fi = Union SM
          proof
            thus union Union fi c= Union SM
            proof
              union Union fi c= union bool Union SM by A22,ZFMISC_1:77;
              hence thesis by ZFMISC_1:81;
            end;
            let v be object;
            assume v in Union SM;
            then consider v0 be set such that
A30:        v in v0 & v0 in rng SM by TARSKI:def 4;
            consider v1 be object such that
A31:        v1 in dom SM &
            v0=SM.v1 by A30,FUNCT_1:def 3;
            reconsider v1 as NatPlus by A31;
            consider n0 be NatPlus, np be Nat such that
A32:        n0<= v1 & np=n0-1 & v in (SM.n0)\Union(SM|Seg np)
            by A30,A31,Lem11;
            FH[n0,fi.n0] by A16;
            then consider x,xp be Nat such that
A33:        n0=x & xp=x-1 &
            fi.n0 is finite Subset of S &
            fi.n0 is a_partition of (SM.n0)\Union (SM|Seg xp);
A34:        union (fi.n0)=(SM.n0)\Union(SM|Seg xp) by A33,EQREL_1:def 4;
            fi.n0 c= Union fi
            proof
              fi.n0 in rng fi by A15,FUNCT_1:def 3;
              hence thesis by ZFMISC_1:74;
            end;
            then union (fi.n0) c= union Union fi by ZFMISC_1:77;
            hence thesis by A32,A33,A34;
          end;
          for A be Subset of Union SM st A in Union fi holds A<>{} &
          for B be Subset of Union SM st B in Union fi holds
          A = B or A misses B
          proof
            let A be Subset of Union SM;
            assume A in Union fi;
            then consider a0 be set such that
A35:        A in a0 & a0 in rng fi by TARSKI:def 4;
            consider a1 be object such that
A36:        a1 in dom fi & a0=fi.a1 by A35,FUNCT_1:def 3;
            FH[a1,fi.a1] by A15,A16,A36;
            then consider xa,xap be Nat such that
A37:        a1=xa & xap=xa-1 &
            fi.a1 is finite Subset of S &
            fi.a1 is a_partition of (SM.a1)\Union (SM|Seg xap);
            for B be Subset of Union SM st B in Union fi holds
            A=B or A misses B
            proof
              let B be Subset of Union SM;
              assume B in Union fi;
              then consider b0 be set such that
A38:          B in b0 & b0 in rng fi by TARSKI:def 4;
              consider b1 be object such that
A39:          b1 in dom fi & b0=fi.b1 by A38,FUNCT_1:def 3;
              FH[b1,fi.b1] by A15,A16,A39;
              then consider xb,xbp be Nat such that
A40:          b1=xb & xbp=xb-1 &
              fi.b1 is finite Subset of S &
              fi.b1 is a_partition of (SM.b1)\Union (SM|Seg xbp);
              not a1=b1 implies A=B or A misses B
              proof
                assume
A41:            not a1=b1;
                reconsider a1 as NatPlus by A15,A36;
                reconsider b1 as NatPlus by A15,A39;
                (SM.a1)\Union(SM|Seg xap) misses (SM.b1)\Union(SM|Seg xbp)
                proof
A42:              a1 < b1 implies (SM.a1)\Union(SM|Seg xap)
                  misses (SM.b1)\Union(SM|Seg xbp)
                  proof
                    assume
A43:                a1 < b1;
                    assume not (((SM.a1)\Union(SM|Seg xap))
                    misses ((SM.b1)\Union(SM|Seg xbp)));
                    then consider u be object such that
A44:                u in ((SM.a1)\Union(SM|Seg xap)) /\
                    ((SM.b1)\Union(SM|Seg xbp)) by XBOOLE_0:def 1;
A45:                u in ((SM.a1)\Union(SM|Seg xap)) & u in
                    ((SM.b1)\Union(SM|Seg xbp))
                    by A44,XBOOLE_0:def 4;
                    u in SM.a1 implies u in Union (SM|Seg xbp)
                    proof
                      assume
A46:                  u in SM.a1;
A47:                  1 <= a1 by CHORD:1;
                      xa < xbp+1 by A37,A40,A43;
                      then xa <= xbp by NAT_1:13;
                      then
A48:                  xa in Seg xbp by A37,A47;
A49:                  a1 in dom (SM|Seg xbp) by A10,A37,A48,RELAT_1:57;
                      then (SM|Seg xbp).a1 in rng (SM|Seg xbp)
                      by FUNCT_1:def 3;
                      then SM.a1 in rng (SM|Seg xbp) by A49,FUNCT_1:47;
                      then SM.a1 c= Union (SM|Seg xbp) by ZFMISC_1:74;
                      hence thesis by A46;
                    end;
                    hence thesis by A45,XBOOLE_0:def 5;
                  end;
                  b1 < a1 implies (SM.a1)\Union(SM|Seg xap) misses
                  (SM.b1)\Union(SM|Seg xbp)
                  proof
                    assume
A50:                b1 < a1;
                    assume
A51:                not (((SM.a1)\Union(SM|Seg xap)) misses
                    ((SM.b1)\Union(SM|Seg xbp)));
A52:                not ((SM.a1)\Union(SM|Seg xap)) /\
                    ((SM.b1)\Union(SM|Seg xbp)) is empty by A51;
                    consider u be object such that
A53:                u in ((SM.a1)\Union(SM|Seg xap)) /\
                    ((SM.b1)\Union(SM|Seg xbp)) by A52;
A54:                u in ((SM.a1)\Union(SM|Seg xap)) &
                    u in((SM.b1)\Union(SM|Seg xbp))
                    by A53,XBOOLE_0:def 4;
                    u in SM.b1 implies u in Union (SM|Seg xap)
                    proof
                      assume
A55:                  u in SM.b1;
A56:                  1 <= b1 by CHORD:1;
                      xb < xap+1 by A37,A40,A50;
                      then xb <= xap by NAT_1:13;
                      then
A57:                  b1 in Seg xap by A40,A56;
A58:                  b1 in dom (SM|Seg xap) by A10,A57,RELAT_1:57;
                      then (SM|Seg xap).b1 in rng (SM|Seg xap)
                      by FUNCT_1:def 3;
                      then SM.b1 in rng (SM|Seg xap) by A58,FUNCT_1:47;
                      then SM.b1 c= Union (SM|Seg xap) by ZFMISC_1:74;
                      hence thesis by A55;
                    end;
                    hence thesis by A54,XBOOLE_0:def 5;
                  end;
                  hence thesis by A41,A42,XXREAL_0:1;
                end;
                hence thesis by A35,A36,A37,A38,A39,A40,XBOOLE_1:64;
              end;
              hence thesis by A35,A36,A37,A38,A39,EQREL_1:def 4;
            end;
            hence thesis by A35,A36,A37;
          end;
          hence thesis by A22,A28,EQREL_1:def 4;
        end;
        thus thesis by A18,A21;
      end;
A59:  for l be Nat holds
      {s where s is Element of S:s in Union fi & s c= Union (SM|Seg l)}=
      Union fi /\ bool (Union(SM|Seg l))
      proof
        let l be Nat;
A60:    {s where s is Element of S:s in Union fi & s c= Union (SM|Seg l)} c=
        Union fi /\ bool (Union(SM|Seg l))
        proof
          let v be object;
          assume v in {s where s is Element of S:s in Union fi &
          s c= Union (SM|Seg l)};
          then consider s0 be Element of S such that
A61:      v=s0 &
          s0 in Union fi & s0 c= Union(SM|Seg l);
          thus thesis by A61,XBOOLE_0:def 4;
        end;
        Union fi /\ bool (Union(SM|Seg l)) c=
        {s where s is Element of S:s in Union fi & s c= Union (SM|Seg l)}
        proof
          let v be object;
          assume
A62:      v in Union fi /\ bool (Union(SM|Seg l));
          then v in Union fi & v in bool (Union(SM|Seg l)) by XBOOLE_0:def 4;
          then consider v0 be set such that
A63:      v in v0 &
          v0 in rng fi by TARSKI:def 4;
          consider n0 be object such that
A64:      n0 in dom fi & v0=fi.n0 by A63,FUNCT_1:def 3;
          FH[n0,fi.n0] by A15,A16,A64;
          then consider x,xp be Nat such that
A65:      n0=x & xp=x-1 &
          fi.n0 is finite Subset of S &
          fi.n0 is a_partition of (SM.n0)\Union (SM|Seg xp);
          v in S & v in Union fi & v in bool (Union(SM|Seg l))
          by A62,A63,A64,A65,XBOOLE_0:def 4;
          hence thesis;
        end;
        hence thesis by A60;
      end;
      for n be NatPlus holds
      Union (SM|Seg n)=
      union{s where s is Element of S:s in Union fi & s c= Union (SM|Seg n)}
      proof
        let n be NatPlus;
A66:    Union (SM|Seg n) c= Union SM by ZFMISC_1:77,RELAT_1:70;
        Union (SM|Seg n) = union(Union fi /\ bool (Union(SM|Seg n)))
        proof
A67:      Union (SM|Seg n) c= union(Union fi /\ bool (Union(SM|Seg n)))
          proof
            let v be object;
            assume
A68:        v in Union (SM|Seg n);
            then v in Union SM by A66;
            then v in union Union fi by A17,EQREL_1:def 4;
            then consider v0 be set such that
A69:        v in v0 & v0 in Union fi by TARSKI:def 4;
            v0  c= Union(SM|Seg n)
            proof
              consider v1 be set such that
A70:          v0 in v1 & v1 in rng fi by A69,TARSKI:def 4;
              consider v2 be object such that
A71:          v2 in dom fi & v1=fi.v2 by A70,FUNCT_1:def 3;
              FH[v2,fi.v2] by A15,A16,A71;
              then consider x2,x2p be Nat such that
A72:          v2=x2 & x2p=x2-1 &
              fi.v2 is finite Subset of S &
              fi.v2 is a_partition of (SM.v2)\Union (SM|Seg x2p);
              not v in Union(SM|Seg x2p) &
              v in Union(SM|Seg n) by A68,A69,A70,A71,A72,XBOOLE_0:def 5;
              then
A73:          v in Union(SM|Seg n) \ Union(SM|Seg x2p) by XBOOLE_0:def 5;
A74:          for n1,n2 be Nat st n1<=n2 holds
              Union(SM|Seg n1) c= Union(SM|Seg n2)
              proof
                let n1,n2 be Nat;
                assume n1<=n2;
                then SM|Seg n1 c= SM|Seg n2 by FINSEQ_1:5,RELAT_1:75;
                hence thesis by RELAT_1:11,ZFMISC_1:77;
              end;
A75:          for n1,n2 be Nat st n1<=n2 holds
              Union(SM|Seg n1) \ Union(SM|Seg n2) ={}
              proof
                let n1,n2 be Nat;
                assume n1<=n2;
                then
A76:            SM|Seg n1 c= SM|Seg n2 by FINSEQ_1:5,RELAT_1:75;
                Union(SM|Seg n1) c= Union(SM|Seg n2)
                by A76,RELAT_1:11,ZFMISC_1:77;
                hence thesis by XBOOLE_1:37;
              end;
              (x2 - 1) + 1 <= n + 1 by XREAL_1:6,A72,A73,A75;
              then
A77:          x2 <= n or x2 = n+1 by NAT_1:8;
              reconsider v2 as Nat by A72;
A78:          v0 c= SM.v2 by A70,A71,A72,XBOOLE_1:1;
              for x be set,i,j be Nat st x c= SM.i & i<=j holds
              x c= Union (SM|Seg j)
              proof
                let x be set;
                let i,j be Nat;
                assume
A79:            x c= SM.i;
                assume
A80:            i<=j;
A81:            (SM.i) c= Union (SM|Seg i)
                proof
                  let y be object;
                  assume
A82:              y in SM.i;
                  per cases;
                  suppose i is zero;
                    then not i in dom SM;
                    hence thesis by A82,FUNCT_1:def 2;
                  end;
                  suppose i is non zero;
                    then
A83:                1<=i & i <= i by CHORD:1;
                    Seg i c= dom SM
                    proof
                      let o be object;
                      assume
A84:                  o in Seg i;
                      then reconsider o as Nat;
                      o is non zero by A84,FINSEQ_1:1;
                      hence thesis by A10,NAT_LAT:def 6;
                    end;
                    then
A85:                dom (SM|Seg i)=Seg i by RELAT_1:62;
A86:                SM.i=(SM|Seg i).i by A83,A85,FINSEQ_1:1,FUNCT_1:47;
                    (SM|Seg i).i in rng (SM|Seg i)
                    by A83,A85,FINSEQ_1:1,FUNCT_1:3;
                    then
                    SM.i c= Union (SM|Seg i) by A86,ZFMISC_1:74;
                    hence thesis by A82;
                  end;
                end;
                Union (SM|Seg i) c= Union (SM|Seg j) by A74,A80;
                then (SM.i) c= Union (SM|Seg j) by A81,XBOOLE_1:1;
                hence thesis by A79,XBOOLE_1:1;
              end;
              hence thesis by A77,A72,A68,A69,A70,A71,A78,XBOOLE_0:def 5;
            end;
            then v in v0 & v0 in Union fi /\ bool (Union (SM|Seg n))
            by A69,XBOOLE_0:def 4;
            hence thesis by TARSKI:def 4;
          end;
          union(Union fi /\ bool (Union(SM|Seg n))) c=
          Union (SM|Seg n)
          proof
A87:        union Union fi /\ union bool (Union(SM|Seg n))=
            union Union fi /\ Union (SM|Seg n) by ZFMISC_1:81;
            union Union fi = Union SM by A17,EQREL_1:def 4;
            then union(Union fi /\ bool (Union(SM|Seg n))) c=
            Union SM /\ Union(SM|Seg n) by A87,ZFMISC_1:79;
            hence thesis by A66,XBOOLE_1:28;
          end;
          hence thesis by A67;
        end;
        hence thesis by A59;
      end;
      hence thesis by A17;
    end;
  end;
