reserve i,n,m for Nat,
  x,y,X,Y for set,
  r,s for Real;

theorem
  for M be non empty MetrSpace st M is complete for A be non empty
Subset of M, A9 be Subset of TopSpaceMetr M st A = A9 holds M|A is complete iff
  A9 is closed
proof
  let M be non empty MetrSpace such that
A1: M is complete;
  set T=TopSpaceMetr(M);
  let A be non empty Subset of M, A9 be Subset of TopSpaceMetr(M) such that
A2: A = A9;
  set MA=M|A;
  set TA=TopSpaceMetr(MA);
  thus MA is complete implies A9 is closed
  proof
    assume
A3: MA is complete;
A4: Cl A9 c= A9
    proof
      let p be object such that
A5:   p in Cl A9;
      reconsider p as Point of M by A5;
      defpred P[object,object] means
for i st i=$1 holds $2=A /\ cl_Ball(p,1/(i+1));
A6:   for x being object st x in NAT
ex y being object st y in bool(the carrier of MA) & P[x,y]
      proof
        let x be object;
        assume x in NAT;
        then reconsider i=x as Nat;
        take A/\cl_Ball(p,1/(i+1));
        A/\cl_Ball(p,1/(i+1)) c= A by XBOOLE_1:17;
        then A/\cl_Ball(p,1/(i+1)) c= the carrier of MA by TOPMETR:def 2;
        hence thesis;
      end;
      consider f be SetSequence of MA such that
A7:   for x being object st x in NAT holds P[x,f.x] from FUNCT_2:sch 1(A6);
A8:   now
        let x be object;
        assume x in dom f;
        then reconsider i=x as Element of NAT;
        reconsider B=Ball(p,1/(i+1)) as Subset of T;
        Ball(p,1/(i+1)) in Family_open_set M by PCOMPS_1:29;
        then
A9:     B is open by PRE_TOPC:def 2;
        p in B by TBSP_1:11,XREAL_1:139;
        then B meets A9 by A5,A9,PRE_TOPC:24;
        then consider y being object such that
A10:    y in B and
A11:    y in A9 by XBOOLE_0:3;
        reconsider y as Point of M by A10;
        dist(p,y)< 1/(i+1) by A10,METRIC_1:11;
        then y in cl_Ball(p,1/(i+1)) by METRIC_1:12;
        then y in A/\cl_Ball(p,1/(i+1)) by A2,A11,XBOOLE_0:def 4;
        hence f.x is non empty by A7;
      end;
A12:  now
        let i;
        reconsider cB=cl_Ball(p,1/(i+1)) as Subset of T;
        reconsider fi=f.i as Subset of TA;
A13:    i in NAT by ORDINAL1:def 12;
        [#]M\cB in Family_open_set(M) by NAGATA_1:14;
        then cB` is open by PRE_TOPC:def 2;
        then
A14:    cB is closed by TOPS_1:3;
A15:    TA=T|A9 by A2,HAUSDORF:16;
        then [#](T|A9)=A by TOPMETR:def 2;
        then fi=cB/\[#](T|A9) by A7,A13;
        then fi is closed by A14,A15,PRE_TOPC:13;
        hence f.i is closed by Th6;
      end;
      now
        let i;
        set ACL=A/\cl_Ball(p,1/(i+1));
        cl_Ball(p,1/(i+1)) is bounded by TOPREAL6:59;
        then
A16:    ACL is bounded by TBSP_1:14,XBOOLE_1:17;
        i in NAT by ORDINAL1:def 12;
        then f.i=ACL by A7;
        hence f.i is bounded by A16,Th15;
      end;
      then reconsider f as non-empty pointwise_bounded closed SetSequence of MA
      by A8,A12,Def1,Def8,FUNCT_1:def 9;
      set df=diameter f;
      reconsider NULL=0,TWO=2 as Real;
      deffunc F(Nat)=1/(1+$1);
      consider seq be Real_Sequence such that
A17:  for n be Nat holds seq.n=F(n) from SEQ_1:sch 1;
      now
        let i be Nat;
        set i1=i+1;
        cl_Ball(p,1/(i1+1)) c= cl_Ball(p,1/i1)
        proof
          let x be object such that
A18:      x in cl_Ball(p,1/(i1+1));
          reconsider q=x as Point of M by A18;
          i1<i1+1 by NAT_1:13;
          then
A19:      1/(i1+1)<1/i1 by XREAL_1:76;
          dist(p,q)<=1/(i1+1) by A18,METRIC_1:12;
          then dist(p,q)<=1/i1 by A19,XXREAL_0:2;
          hence thesis by METRIC_1:12;
        end;
        then
A20:    A/\cl_Ball(p,1/(i1+1)) c= A/\cl_Ball(p,1/i1) by XBOOLE_1:26;
        i in NAT by ORDINAL1:def 12;
        then f.i=A/\cl_Ball(p,1/i1) by A7;
        hence f.(i+1) c= f.i by A7,A20;
      end;
      then
A21:  f is non-ascending by KURATO_0:def 3;
      set Ts=TWO(#)seq;
      set Ns=NULL(#)seq;
A22:  for n be Nat holds seq.n=1/(n+1) by A17;
      then
A23:  Ns is convergent by SEQ_2:7,SEQ_4:31;
A24:  now
        let n be Nat;
        set cB=cl_Ball(p,1/(n+1));
A25:    Ns.n=NULL*seq.n by SEQ_1:9;
A26:    Ts.n=TWO*seq.n by SEQ_1:9;
A27:    cB is bounded by TOPREAL6:59;
        then
A28:    A/\cB is bounded by TBSP_1:14,XBOOLE_1:17;
A29:    diameter(A/\cB)<= diameter cB by A27,TBSP_1:24,XBOOLE_1:17;
        diameter cB <= 2*F(n) by Th5;
        then
A30:    diameter(A/\cB)<=2*F(n) by A29,XXREAL_0:2;
        n in NAT by ORDINAL1:def 12;
        then
A31:    f.n=A/\cB by A7;
        then f.n is bounded by A28,Th15;
        then
A32:    0<= diameter f.n by TBSP_1:21;
        diameter (f.n) <= diameter(A/\cB) by A28,A31,Th16;
        then
A33:    diameter f.n <= 2*F(n) by A30,XXREAL_0:2;
        F(n)=seq.n by A17;
        hence Ns.n <= df.n & df.n<=Ts.n by A32,A33,A25,A26,Def2;
      end;
A34:  Ts is convergent by A22,SEQ_2:7,SEQ_4:31;
A35:  lim seq=0 by A22,SEQ_4:31;
      then
A36:  lim Ts= TWO*0 by A22,SEQ_2:8,SEQ_4:31;
      lim Ns=NULL*0 by A22,A35,SEQ_2:8,SEQ_4:31;
      then lim df = 0 by A23,A34,A36,A24,SEQ_2:20;
      then meet f is non empty by A3,A21,Th10;
      then consider q be object such that
A37:  q in meet f by XBOOLE_0:def 1;
      reconsider q as Point of M by A37,TOPMETR:8;
A38:  seq is convergent by A22,SEQ_4:31;
      p = q
      proof
        assume p <> q;
        then dist(p,q)<>0 by METRIC_1:2;
        then dist(p,q)>0 by METRIC_1:5;
        then consider n be Nat such that
A39:    for m be Nat st n<=m holds |.seq.m-0.|<dist(p,q)
        by A38,A35,SEQ_2:def 7;
        set cB=cl_Ball(p,1/(n+1));
A40:    q in f.n by A37,KURATO_0:3;
        n in NAT by ORDINAL1:def 12;
        then f.n = A/\cB by A7;
        then q in cB by A40,XBOOLE_0:def 4;
        then
A41:    dist(p,q) <= F(n) by METRIC_1:12;
        seq.n = F(n) by A17;
        then |.seq.n-0.|=F(n) by ABSVALUE:def 1;
        hence thesis by A39,A41;
      end;
      then
A42:  p in f.0 by A37,KURATO_0:3;
      f.0=A/\cl_Ball(p,1/(0+1)) by A7;
      hence thesis by A2,A42,XBOOLE_0:def 4;
    end;
    A9 c= Cl A9 by PRE_TOPC:18;
    hence thesis by A4,XBOOLE_0:def 10;
  end;
  assume
A43: A9 is closed;
  let S be sequence of MA such that
A44: S is Cauchy;
  reconsider S9=S as sequence of M by Th17;
  S9 is Cauchy by A44,Th18;
  then
A45: S9 is convergent by A1;
A46: now
    let n be Nat;
    S.n in the carrier of (M|A);
    hence S9.n in A9 by A2,TOPMETR:def 2;
  end;
  the carrier of (M|A)=A9 by A2,TOPMETR:def 2;
  then reconsider limS=lim S9 as Point of (M|A) by A43,A45,A46,TOPMETR3:1;
  take limS;
  let r;
  assume r>0;
  then consider n be Nat such that
A47: for m be Nat st m>=n holds dist(S9.m,lim S9)<r by A45,
TBSP_1:def 3;
  take n;
  let m be Nat such that
A48: m>=n;
  dist(S.m,limS) = dist(S9.m,lim S9) by TOPMETR:def 1;
  hence thesis by A47,A48;
end;
