
theorem Th13:
  for S be non empty compact TopSpace,T be non empty MetrSpace
      st T is complete holds
    MetricSpace_of_ContinuousFunctions(S,T) is complete
  proof
    let S be non empty compact TopSpace,T be non empty MetrSpace;
    assume A1: T is complete;
    set MSC = MetricSpace_of_ContinuousFunctions(S,T);
    set A = ContinuousFunctions (S,T);
    now let v be sequence of MSC;
      assume a2: v is Cauchy; then
  A2: for r being Real st r > 0 holds
      ex p being Nat st
      for n, m being Nat st p <= n & p <= m holds dist (v.n,v.m) < r;
      defpred P[set,set] means ex xseq be sequence of T st
      for n be Nat holds xseq.n=In((v.n).$1,T) &
      xseq is convergent & $2= lim xseq;
  A3: for x be Element of S ex y be Element of T st P[x,y]
      proof
        let x be Element of S;
        deffunc F(Nat) = In((v.$1).x,T);
        consider xseq be sequence of T such that
A4:     for n be Element of NAT holds xseq.n = F(n) from FUNCT_2:sch 4;
A5:     for n be Nat holds xseq.n = F(n)
        proof let n be Nat;
          n in NAT by ORDINAL1:def 12;
          hence thesis by A4;
        end;
        take lx = lim xseq;
    A6: for m,k be Nat holds dist(xseq.m,xseq.k) <= dist(v.m,v.k)
        proof
          let m,k be Nat;
          xseq.m = In((v.m).x,T) & xseq.k =In((v.k).x,T) by A5;
          hence thesis by Th11;
        end;
        now
          let e be Real such that
    A7:   e > 0;
          consider k be Nat such that
A8:       for n, m be Nat st n >= k & m >= k holds
          dist(v.n,v.m) < e by A7,a2;
          take k;
          let n,m be Nat;
          assume n >=k & m >= k; then
   A9:    dist(v.n,v.m) < e by A8;
          dist(xseq.n,xseq.m) <= dist(v.n,v.m) by A6;
          hence dist(xseq.n,xseq.m) < e by A9,XXREAL_0:2;
        end;
        then xseq is Cauchy;
        hence thesis by A1,A5;
      end;
      consider tseq0 be Function of S,T such that
A10:  for x be Element of S holds P[x,tseq0.x] from FUNCT_2:sch 3(A3);
      reconsider tseq=tseq0 as Function of S,TopSpaceMetr(T);
      for x being Point of S holds tseq is_continuous_at x
      proof
        let x be Point of S;
        consider xseq be sequence of T such that
 A11:   for n be Nat holds xseq.n=In((v.n).x,T) &
        xseq is convergent & tseq0.x= lim xseq by A10;
        now let e be Real;
          assume A12: 0 < e;
          consider N1 being Nat such that
     A13: for n, m being Nat st N1 <= n & N1 <= m holds
          dist (v.n,v.m) < e/4 by a2,A12;
A14:      for n, m being Nat st N1 <= n & N1 <= m
          for x be Point of S holds dist (In((v.n).x,T), In((v.m).x,T)) < e/4
          proof
            let n, m be Nat;
            assume A15: N1 <= n & N1 <= m;
            let x be Point of S;
   A16:     dist (In((v.n).x,T), In((v.m).x,T)) <= dist(v.n,v.m) by Th11;
            dist (v.n,v.m) < e/4 by A13,A15;
            hence thesis by A16,XXREAL_0:2;
          end;
          consider N2 being Nat such that
A17:      for m being Nat st m >= N2 holds
          dist (xseq.m,tseq0.x) < e/4 by A11,A12,TBSP_1:def 3;
          reconsider N3 = max(N1,N2) as Nat by XXREAL_0:16;
A18:      N2 <= N3 & N1 <= N3 by XXREAL_0:25; then
A19:      dist (xseq.N3,tseq0.x) < e/4 by A17;
A20:      xseq.N3 = In((v.N3).x,T) by A11;
          v.N3 in A; then
          consider vN3 be Function of S,TopSpaceMetr(T) such that
     A21: v.N3=vN3 & vN3 is continuous;
          consider H being Subset of S such that
A22:      H is open & x in H &
          for y be Point of S st y in H holds
          dist(In(vN3.x,T),In(vN3.y,T)) < e/4 by Th2,A12,TMAP_1:50,A21;
          take H;
          thus H is open & x in H by A22;
          let y be Point of S;
          assume y in H; then
A23:      dist(In(vN3.x,T),In(vN3.y,T))< e/4 by A22;
          consider yseq be sequence of T such that
A24:      for n be Nat holds yseq.n=In((v.n).y,T) &
          yseq is convergent & tseq0.y = lim yseq by A10;
          consider N4 being Nat such that
A25:      for m being Nat st m >= N4 holds
          dist (yseq.m,tseq0.y) < e/4 by A24,A12,TBSP_1:def 3;
          reconsider N5 = max(N3,N4) as Nat by XXREAL_0:16;
a26:      N4 <= N5 & N3 <= N5 by XXREAL_0:25; then
A26:      N1 <= N5 by A18,XXREAL_0:2;
A27:      dist (yseq.N5,tseq0.y) < e/4 by a26,A25;
A28:      dist (tseq0.x,tseq0.y) <=
            dist (tseq0.x,yseq.N5)+ dist (yseq.N5,tseq0.y) by METRIC_1:4;
A29:      dist (tseq0.x,yseq.N5)
            <= dist (tseq0.x,xseq.N3)+ dist (xseq.N3,yseq.N5)
              by METRIC_1:4;
A30:      dist (xseq.N3,yseq.N5)
            <= dist (xseq.N3,yseq.N3) + dist (yseq.N3,yseq.N5)
              by METRIC_1:4;
A31:      dist (In((v.N3).y,T), In((v.N5).y,T)) < e/4 by A14,A18,A26;
          yseq.N3=In((v.N3).y,T) by A24; then
A33:      dist (yseq.N3,yseq.N5) < e/4 by A24,A31;
A34:      xseq.N3 = In((v.N3).x,T) by A20
             .=In(vN3.x,T) by A21;
          yseq.N3 = In((v.N3).y,T) by A24
            .=In(vN3.y,T) by A21; then
          dist (xseq.N3,yseq.N3) + dist (yseq.N3,yseq.N5)
            < e/4 + e/4 by A23,A34,A33,XREAL_1:8; then
          dist (xseq.N3,yseq.N5) < e/2 by A30,XXREAL_0:2; then
          dist (tseq0.x,xseq.N3) + dist (xseq.N3,yseq.N5)
            < e/4 + e/2 by A19,XREAL_1:8; then
          dist (tseq0.x,yseq.N5) < e/4 + e/2 by A29,XXREAL_0:2;
            then
          dist (tseq0.x,yseq.N5) + dist (yseq.N5,tseq0.y)
            < e/4 + e/2 + e/4 by A27,XREAL_1:8;
          hence dist (In(tseq.x,T),In(tseq.y,T)) < e by A28,XXREAL_0:2;
        end;
        hence thesis by Th2;
      end; then
      tseq is continuous Function of S,TopSpaceMetr(T)
        by TMAP_1:50; then
      tseq in MSC;
      then reconsider w = tseq as Point of MSC;
      for e being Real st e > 0 holds ex N being Nat st
      for m being Nat st N <= m holds dist (v.m,w) < e
      proof
        let e be Real;
        assume A36: e > 0; then
        consider N1 being Nat such that
A37:    for n, m being Nat st N1 <= n & N1 <= m holds
        dist (v.n,v.m) < e/4 by A2;
A38:    for n, m being Nat st N1 <= n & N1 <= m
        for x be Point of S
          holds dist (In((v.n).x,T), In((v.m).x,T)) < e/4
        proof
          let n, m be Nat;
          assume A39: N1 <= n & N1 <= m;
          let x be Point of S;
   A40:   dist (In((v.n).x,T), In((v.m).x,T))
            <= dist(v.n,v.m) by Th11;
          dist (v.n,v.m) < e/4 by A37,A39;
          hence thesis by A40,XXREAL_0:2;
        end;
        take N1;
        let m be Nat;
        assume A41: N1 <= m;
        v.m in A; then
        consider vm be Function of S,TopSpaceMetr(T) such that
   A42: v.m=vm & vm is continuous;
        reconsider vm as Function of S,T;
        for x be Point of S holds dist (vm.x,tseq0.x) <= e/2
        proof
          let x be Point of S;
          consider xseq be sequence of T such that
 A43:     for n be Nat holds xseq.n=In((v.n).x,T) &
            xseq is convergent & tseq0.x= lim xseq by A10;
          consider N2 being Nat such that
A44:      for m being Nat st m >= N2 holds
          dist (xseq.m,tseq0.x) < e/4 by A43,A36,TBSP_1:def 3;
          reconsider N3 = max(N1,N2) as Nat by XXREAL_0:16;
A45:      N2 <= N3 & N1 <= N3 by XXREAL_0:25; then
A46:      dist (xseq.N3,tseq0.x) < e/4 by A44;
A47:      dist (In((v.N3).x,T), In((v.m).x,T)) < e/4 by A41,A45,A38;
A48:      xseq.N3=In((v.N3).x,T) by A43;
A49:      dist (In((v.m).x,T),tseq0.x) <= dist (In((v.m).x,T),In((v.N3).x,T))
            + dist (In((v.N3).x,T),tseq0.x) by METRIC_1:4;
          dist (In((v.m).x,T),In((v.N3).x,T)) < e/4 by A47; then
          dist (In((v.m).x,T),In((v.N3).x,T))
            + dist (In((v.N3).x,T),tseq0.x) < e/4 + e/4
              by A46,A48,XREAL_1:8;
          hence dist (vm.x,tseq0.x) <= e/2 by A42,A49,XXREAL_0:2;
        end; then
   A51: dist (v.m,w) <= e/2 by Th12,A42;
        e/2 < e by A36,XREAL_1:216;
        hence dist (v.m,w) < e by A51,XXREAL_0:2;
      end;
      hence v is convergent;
    end;
    hence thesis;
  end;
