reserve r for Real;
reserve a, b for Real;
reserve T for non empty TopSpace;
reserve A for non empty SubSpace of T;
reserve P,Q for Subset of T,
  p for Point of T;
reserve M for non empty MetrSpace,
  p for Point of M;
reserve A for non empty SubSpace of M;
reserve F,G for Subset-Family of M;

theorem
  M is compact iff for F st F is being_ball-family & F is Cover of M ex
  G st G c= F & G is Cover of M & G is finite
proof
  thus M is compact implies for F st F is being_ball-family & F is Cover of M
  ex G st G c= F & G is Cover of M & G is finite
  proof
    set TM = TopSpaceMetr(M);
    assume M is compact;
    then
A1: TopSpaceMetr(M) is compact;
    let F;
    reconsider TF = F as Subset-Family of TM;
    assume that
A2: F is being_ball-family and
A3: F is Cover of M;
A4: TF is open
    proof
      let P be Subset of TM;
      reconsider P9 = P as Subset of M;
      assume P in TF;
      then ex p,r st P9 = Ball(p,r) by A2;
      hence thesis by Th14;
    end;
    the carrier of M c= union F by A3,SETFAM_1:def 11;
    then the carrier of TM c= union TF;
    then TF is Cover of TM by SETFAM_1:def 11;
    then consider TG being Subset-Family of TM such that
A5: TG c= TF and
A6: TG is Cover of TM and
A7: TG is finite by A1,A4,COMPTS_1:def 1;
    reconsider G = TG as Subset-Family of M;
    take G;
    the carrier of TM c= union TG by A6,SETFAM_1:def 11;
    then the carrier of M c= union G;
    hence thesis by A5,A7,SETFAM_1:def 11;
  end;
  thus (for F st F is being_ball-family & F is Cover of M ex G st G c= F & G
  is Cover of M & G is finite) implies M is compact
  proof
    set TM = TopSpaceMetr(M);
    assume
A8: for F st F is being_ball-family & F is Cover of M ex G st G c= F
    & G is Cover of M & G is finite;
    now
      let F be Subset-Family of TM;
      set Z = { Ball(p,r) where p is Point of M, r is Real: ex P being Subset
      of TM st P in F & Ball(p,r) c= P};
      Z c= bool the carrier of M
      proof
        let a be object;
        assume a in Z;
        then
        ex p being Point of M, r being Real st a = Ball(p,r) & ex P being
        Subset of TM st P in F & Ball(p,r) c= P;
        hence thesis;
      end;
      then reconsider Z as Subset-Family of M;
      assume that
A9:   F is Cover of TM and
A10:  F is open;
      the carrier of M c= union Z
      proof
        let a be object;
        assume a in the carrier of M;
        then reconsider p = a as Point of M;
        the carrier of TM c= union F & the carrier of TM = the carrier of
        M by A9,SETFAM_1:def 11;
        then p in union F;
        then consider P being set such that
A11:    p in P and
A12:    P in F by TARSKI:def 4;
        reconsider P as Subset of TM by A12;
        P is open by A10,A12;
        then consider r being Real such that
A13:    r>0 and
A14:    Ball(p,r) c= P by A11,Th15;
        reconsider r9 = r as Element of REAL by XREAL_0:def 1;
A15:    a in Ball(p,r) by A13,TBSP_1:11;
        Ball(p,r9) in Z by A12,A14;
        hence thesis by A15,TARSKI:def 4;
      end;
      then
A16:  Z is Cover of M by SETFAM_1:def 11;
      reconsider F9 = F as non empty Subset-Family of TM by A9,TOPS_2:3;
      defpred X[object,object] means
          ex D1,D2 being set st D1 = $1 & D2 = $2 & D1 c= D2;
      Z is being_ball-family
      proof
        let P be set;
        assume P in Z;
        then
        ex p being Point of M, r being Real st P = Ball(p,r) & ex P being
        Subset of TM st P in F & Ball(p,r) c= P;
        hence thesis;
      end;
      then consider G being Subset-Family of M such that
A17:  G c= Z and
A18:  G is Cover of M and
A19:  G is finite by A8,A16;
A20:  for a being object st a in G ex u being object st u in F9 & X[a,u]
      proof
        let a be object;
        assume a in G;
        then a in Z by A17;
        then consider p being Point of M, r being Real such that
A21:    Ball(p,r) = a and
A22:    ex P being Subset of TM st P in F & Ball(p,r) c= P;
        consider P being Subset of TM such that
A23:    P in F & Ball(p,r) c= P by A22;
        take P;
        thus thesis by A21,A23;
      end;
      consider f being Function of G,F9 such that
A24:  for a being object st a in G holds X[a,f.a] from FUNCT_2:sch 1(A20
      );
      reconsider GG = rng f as Subset-Family of TM by TOPS_2:2;
      take GG;
      thus GG c= F;
      the carrier of TM c= union GG
      proof
A25:    the carrier of TM = the carrier of M & the carrier of M c= union
        G by A18,SETFAM_1:def 11;
        let a be object;
        assume a in the carrier of TM;
        then consider P being set such that
A26:    a in P and
A27:    P in G by A25,TARSKI:def 4;
        X[P,f.P] by A24,A27;
        then
A28:    P c= f.P;
        dom f = G by FUNCT_2:def 1;
        then f.P in GG by A27,FUNCT_1:def 3;
        hence thesis by A26,A28,TARSKI:def 4;
      end;
      hence GG is Cover of TM by SETFAM_1:def 11;
      dom f = G by FUNCT_2:def 1;
      hence GG is finite by A19,FINSET_1:8;
    end;
    then TM is compact by COMPTS_1:def 1;
    hence thesis;
  end;
end;
