reserve M for non empty MetrSpace,
  c,g1,g2 for Element of M;
reserve N for non empty MetrStruct,
  w for Element of N,
  G for Subset-Family of N,
  C for Subset of N;
reserve R for Reflexive non empty MetrStruct;
reserve T for Reflexive symmetric triangle non empty MetrStruct,
  t1 for Element of T,
  Y for Subset-Family of T,
  P for Subset of T;
reserve f for Function,
  n,m,p,n1,n2,k for Nat,
  r,s,L for Real,
  x,y for set;
reserve S1 for sequence of M,
  S2 for sequence of N;

theorem
  TopSpaceMetr(T) is compact implies T is complete
proof
  set TM = TopSpaceMetr(T);
A1: TM = TopStruct (# the carrier of T,Family_open_set(T) #) by PCOMPS_1:def 5;
  assume
A2: TopSpaceMetr(T) is compact;
  let S2 be sequence of T such that
A3: S2 is Cauchy;
  S2 is convergent
  proof
A4: for p holds {x where x is Point of T : ex n st p<=n & x = S2.n} <> {}
    proof
      let p be Nat;
      (S2.p) in {x where x is Point of T : ex n st p<=n & x = S2.n};
      hence thesis;
    end;
    defpred X[Subset of TopSpaceMetr T] means ex p st $1 = {x where x is Point
    of T : ex n st p<=n & x = S2.n};
    consider F being Subset-Family of TopSpaceMetr(T) such that
A5: for B being Subset of TopSpaceMetr(T) holds B in F iff X[B] from
    SUBSET_1:sch 3;
    defpred X[Point of T] means ex n st 0<=n & $1 = S2.n;
    set B0 = {x where x is Point of T : X[x]};
A6: B0 is Subset of T from DOMAIN_1:sch 7;
    then
A7: B0 in F by A1,A5;
    reconsider B0 as Subset of TopSpaceMetr(T) by A1,A6;
    reconsider F as Subset-Family of TopSpaceMetr(T);
    set G = clf F;
A8: Cl B0 in G by A7,PCOMPS_1:def 2;
A9: G is centered
    proof
      thus G<>{} by A8;
      let H be set such that
A10:  H <> {} and
A11:  H c= G and
A12:  H is finite;
A13:  H c= bool the carrier of TM by A11,XBOOLE_1:1;
      H is c=-linear
      proof
        let B,C be set;
        assume that
A14:    B in H and
A15:    C in H;
        reconsider B, C as Subset of TM by A13,A14,A15;
        consider V being Subset of TM such that
A16:    B = Cl V and
A17:    V in F by A11,A14,PCOMPS_1:def 2;
        consider p such that
A18:    V = {x where x is Point of T : ex n st p<=n & x = S2.n} by A5,A17;
        consider W being Subset of TM such that
A19:    C = Cl W and
A20:    W in F by A11,A15,PCOMPS_1:def 2;
        consider q being Nat such that
A21:    W = {x where x is Point of T : ex n st q<=n & x = S2.n} by A5,A20;
        now
          per cases;
          case
A22:        q<=p;
            thus V c= W
            proof
              let y be object;
              assume y in V;
              then consider x being Point of T such that
A23:          y = x and
A24:          ex n st p<=n & x = S2.n by A18;
              consider n such that
A25:          p<=n and
A26:          x = S2.n by A24;
              q<=n by A22,A25,XXREAL_0:2;
              hence thesis by A21,A23,A26;
            end;
          end;
          case
A27:        p<=q;
            thus W c= V
            proof
              let y be object;
              assume y in W;
              then consider x being Point of T such that
A28:          y = x and
A29:          ex n st q<=n & x = S2.n by A21;
              consider n such that
A30:          q<=n and
A31:          x = S2.n by A29;
              p<=n by A27,A30,XXREAL_0:2;
              hence thesis by A18,A28,A31;
            end;
          end;
        end;
        then B c= C or C c= B by A16,A19,PRE_TOPC:19;
        hence thesis;
      end;
      then consider m being set such that
A32:  m in H and
A33:  for C being set st C in H holds m c= C by A10,A12,FINSET_1:11;
A34:  m c= meet H by A10,A33,SETFAM_1:5;
      reconsider m as Subset of TM by A13,A32;
      consider A being Subset of TM such that
A35:  m = Cl A and
A36:  A in F by A11,A32,PCOMPS_1:def 2;
      A <> {} by A5,A4,A36;
      then m <> {} by A35,PRE_TOPC:18,XBOOLE_1:3;
      hence thesis by A34;
    end;
    G is closed by PCOMPS_1:11;
    then meet G <> {} by A2,A9,COMPTS_1:4;
    then consider c being Point of TM such that
A37: c in meet G by SUBSET_1:4;
    reconsider c as Point of T by A1;
    take c;
    let r;
    assume 0<r;
    then
A38: 0<r/2 by XREAL_1:215;
    then consider p such that
A39: for n,m st p<=n & p<=m holds dist(S2.n,S2.m)<r/2 by A3;
    dist(c,c)<r/2 by A38,METRIC_1:1;
    then
A40: c in Ball(c,r/2) by METRIC_1:11;
    reconsider Z = Ball(c,r/2) as Subset of TopSpaceMetr(T) by A1;
    Ball(c,r/2) in Family_open_set(T) by PCOMPS_1:29;
    then
A41: Z is open by A1,PRE_TOPC:def 2;
    defpred X[set] means ex n st p<=n & $1 = S2.n;
    set B = {x where x is Point of T : X[x]};
A42: B is Subset of T from DOMAIN_1:sch 7;
    then
A43: B in F by A1,A5;
    reconsider B as Subset of TopSpaceMetr(T) by A1,A42;
    Cl B in G by A43,PCOMPS_1:def 2;
    then c in Cl B by A37,SETFAM_1:def 1;
    then B meets Z by A40,A41,PRE_TOPC:def 7;
    then consider g being object such that
A44: g in B /\ Z by XBOOLE_0:4;
    take p;
    let m;
A45: g in B by A44,XBOOLE_0:def 4;
A46: g in Z by A44,XBOOLE_0:def 4;
    then reconsider g as Point of T;
    consider x being Point of T such that
A47: g = x and
A48: ex n st p<=n & x = S2.n by A45;
    consider n such that
A49: p<=n and
A50: x = S2.n by A48;
    assume p<=m;
    then
A51: dist(S2.m,S2.n)<r/2 by A39,A49;
    dist(S2.n,c)<r/2 by A46,A47,A50,METRIC_1:11;
    then
A52: dist(S2.m,S2.n)+dist(S2.n,c)<r/2+r/2 by A51,XREAL_1:8;
    dist(S2.m,c)<=dist(S2.m,S2.n)+dist(S2.n,c) by METRIC_1:4;
    hence thesis by A52,XXREAL_0:2;
  end;
  hence thesis;
end;
