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

theorem
  for M be triangle Reflexive non empty MetrStruct for a be Point of M
  for X be non empty set holds WellSpace(a,X) is complete implies M is complete
proof
  let M be triangle Reflexive non empty MetrStruct;
  let a be Point of M;
  let X be non empty set;
  consider x0 be object such that
A1: x0 in X by XBOOLE_0:def 1;
  set W=WellSpace(a,X);
  assume
A2: WellSpace(a,X) is complete;
  let S be sequence of M such that
A3: S is Cauchy;
  defpred P[object,object] means
  (S.$1<>a implies $2=[x0,S.$1]) & (S.$1=a implies $2 =[X,S.$1]);
A4: for x being object st x in NAT
ex y being object st y in the carrier of W & P[x,y]
  proof
    let x be object;
    assume x in NAT;
    then reconsider i=x as Nat;
    per cases;
    suppose
A5:   S.i<>a;
      take [x0,S.i];
      thus thesis by A1,A5,Th37;
    end;
    suppose
A6:   S.x=a;
      take [X,a];
      thus thesis by A6,Th37;
    end;
  end;
  consider S9 be sequence of W such that
A7: for x being object st x in NAT holds P[x,S9.x] from FUNCT_2:sch 1(A4);
  S9 is Cauchy
  proof
    let r;
    assume r>0;
    then consider p be Nat such that
A8: for n,m be Nat st p<=n & p<=m holds dist(S.n,S.m)<r by A3;
    take p;
    let n,m be Nat such that
A9: p <= n and
A10: p <= m;
A11:  n in NAT & m in NAT by ORDINAL1:def 12;
    per cases;
    suppose
A12:  S.n=a & S.m=a;
      then
A13:  [X,S.m]=S9.m by A7,A11;
      [X,S.n]=S9.n by A7,A12,A11;
      then dist(S9.n,S9.m)=dist(S.n,S.m) by A13,Def10;
      hence thesis by A8,A9,A10;
    end;
    suppose
A14:  S.n<>a & S.m=a;
      then
A15:  [X,S.m]=S9.m by A7,A11;
A16:  dist(S.m,S.m)=0 by METRIC_1:1;
          reconsider xx = x0 as set by TARSKI:1;
          not xx in xx; then
A17:  X<>x0 by A1;
      [x0,S.n]=S9.n by A7,A14,A11;
      then dist(S9.n,S9.m)=dist(S.n,S.m)+dist(S.m,S.m) by A14,A15,A17,Def10;
      hence thesis by A8,A9,A10,A16;
    end;
    suppose
A18:  S.n=a & S.m<>a;
      then
A19:  [x0,S.m]=S9.m by A7,A11;
A20:  dist(S.n,S.n)=0 by METRIC_1:1;
          reconsider xx = x0 as set by TARSKI:1;
          not xx in xx; then
A21:  X<>x0 by A1;
      [X,S.n]=S9.n by A7,A18,A11;
      then dist(S9.n,S9.m)=dist(S.n,S.n)+dist(S.n,S.m) by A18,A19,A21,Def10;
      hence thesis by A8,A9,A10,A20;
    end;
    suppose
A22:  S.n<>a & S.m<>a;
      then
A23:  [x0,S.m]=S9.m by A7,A11;
      [x0,S.n]=S9.n by A7,A22,A11;
      then dist(S9.n,S9.m)=dist(S.n,S.m) by A23,Def10;
      hence thesis by A8,A9,A10;
    end;
  end;
  then S9 is convergent by A2;
  then consider L being Element of W such that
A24: for r st r>0 ex n be Nat st for m be Nat st n
  <=m holds dist(S9.m,L)<r;
  consider L1 be set,L2 be Point of M such that
A25: L=[L1,L2] and
  L1 in X & L2<>a or L1 = X & L2 = a by Th37;
  take L2;
  let r;
  assume r>0;
  then consider n be Nat such that
A26: for m be Nat st n<=m holds dist(S9.m,L)<r by A24;
  take n;
  let m be Nat such that
A27: n<=m;
A28:  n in NAT & m in NAT by ORDINAL1:def 12;
  per cases;
  suppose
A29: S.m=a & L1=X;
    then S9.m=[X,a] by A7,A28;
    then dist(S9.m,L)=dist(S.m,L2) by A25,A29,Def10;
    hence thesis by A26,A27;
  end;
  suppose
A30: S.m=a & L1<>X;
    then S9.m=[X,a] by A7,A28;
    then
A31: dist(S9.m,L)=dist(S.m,S.m)+dist(S.m,L2) by A25,A30,Def10;
    dist(S.m,S.m)=0 by METRIC_1:1;
    hence thesis by A26,A27,A31;
  end;
  suppose
A32: S.m <> a & L1=x0;
    then S9.m=[x0,S.m] by A7,A28;
    then dist(S9.m,L)=dist(S.m,L2) by A25,A32,Def10;
    hence thesis by A26,A27;
  end;
  suppose
A33: S.m <> a & L1<>x0;
    then S9.m=[x0,S.m] by A7,A28;
    then
A34: dist(S9.m,L)=dist(S.m,a)+dist(a,L2) by A25,A33,Def10;
A35: dist(S.m,a)+dist(a,L2)>= dist(S.m,L2) by METRIC_1:4;
    dist(S9.m,L)<r by A26,A27;
    hence thesis by A34,A35,XXREAL_0:2;
  end;
end;
