reserve n,n1,m,m1,k for Nat;
reserve x,X,X1 for set;
reserve g,g1,g2,t,x0,x1,x2 for Complex;
reserve s1,s2,q1,seq,seq1,seq2,seq3 for Complex_Sequence;
reserve Y for Subset of COMPLEX;
reserve f,f1,f2,h,h1,h2 for PartFunc of COMPLEX,COMPLEX;
reserve p,r,s for Real;
reserve Ns,Nseq for increasing sequence of NAT;

theorem
  f is_continuous_in x0 iff x0 in dom f & for s1 st rng s1 c= dom f & s1
is convergent & lim s1=x0 & (for n holds s1.n<>x0) holds f/*s1 is convergent &
  f/.x0=lim(f/*s1)
proof
  thus f is_continuous_in x0 implies x0 in dom f & for s1 st rng s1 c= dom f &
s1 is convergent & lim s1=x0 & (for n holds s1.n<>x0) holds f/*s1 is convergent
  & f/.x0=lim(f/*s1);
  assume that
A1: x0 in dom f and
A2: for s1 st rng s1 c=dom f & s1 is convergent & lim s1=x0 & (for n
  holds s1.n<>x0) holds f/*s1 is convergent & f/.x0=lim(f/*s1);
  thus x0 in dom f by A1;
  let s2 such that
A3: rng s2 c=dom f and
A4: s2 is convergent & lim s2=x0;
  now
    per cases;
    suppose
      ex n st for m st n<=m holds s2.m=x0;
      then consider N be Nat such that
A5:   for m st N<=m holds s2.m=x0;
A6:   for n holds (s2^\N).n=x0
      proof
        let n;
        s2.(n+N)=x0 by A5,NAT_1:12;
        hence thesis by NAT_1:def 3;
      end;
A7:   f/*(s2^\N)=(f/*s2)^\N by A3,VALUED_0:27;
A8:   rng (s2^\N) c= rng s2 by VALUED_0:21;
A9:   now
        let p such that
A10:    p>0;
         reconsider n=0 as Nat;
        take n;
        let m such that
        n<=m;
        m in NAT by ORDINAL1:def 12;
        then |.(f/*(s2^\N)).m-f/.x0.|=|.f/.((s2^\N).m)-f/.x0.|
              by A3,A8,FUNCT_2:109
,XBOOLE_1:1
          .=|.f/.x0-f/.x0.| by A6
          .=0 by COMPLEX1:44;
        hence |.(f/*(s2^\N)).m-f/.x0.|<p by A10;
      end;
      then
A11:  f/*(s2^\N) is convergent;
      then f/.x0=lim((f/*s2)^\N) by A9,A7,COMSEQ_2:def 6;
      hence thesis by A11,A7,Th18,Th22;
    end;
    suppose
A12:  for n ex m st n<=m & s2.m<>x0;
      defpred P2[set,set] means for n,m st $1=n & $2=m holds n<m & s2.m<>x0 &
      for k st n<k & s2.k<>x0 holds m<=k;
      defpred R[set,set,set] means P2[$2,$3];
      defpred P[set] means s2.$1<>x0;
      ex m1 be Nat st 0<=m1 & s2.m1<>x0 by A12;
      then
A13:  ex m be Nat st P[m];
      consider M be Nat such that
A14:  P[M] & for n be Nat st P[n] holds M<=n from NAT_1:sch 5(A13);
      reconsider M9 = M as Element of NAT by ORDINAL1:def 12;
A15:  now
        let n;
        consider m such that
A16:    n+1<=m & s2.m<>x0 by A12;
        take m;
        thus n<m & s2.m<>x0 by A16,NAT_1:13;
      end;
A17:  for n being Nat
       for x be Element of NAT ex y be Element of NAT st R[n,x,y]
      proof
        let n be Nat;
        let x be Element of NAT;
        defpred P[Nat] means x<$1 & s2.$1<>x0;
        ex m st P[m] by A15;
        then
A18:    ex m be Nat st P[m];
        consider l be Nat such that
A19:    P[l] & for k be Nat st P[k] holds l<=k from NAT_1:sch 5(A18);
        take l;
        l in NAT by ORDINAL1:def 12;
        hence thesis by A19;
      end;
      consider F be sequence of NAT such that
A20:  F.0=M9 & for n be Nat holds R[n,F.n,F.(n+1)] from
      RECDEF_1:sch 2(A17);
A21:  for n holds F.n is real;
  dom F=NAT by FUNCT_2:def 1;
      then reconsider F as Real_Sequence by A21,SEQ_1:2;
      for n holds F.n<F.(n+1) by A20;
      then reconsider F as increasing sequence of NAT by SEQM_3:def 6;
A22:  s2*F is subsequence of s2 by VALUED_0:def 17;
      then
A23:  s2*F is convergent & lim (s2*F)=x0 by A4,Th17,Th18;
A24:  for n st s2.n<>x0 ex m st F.m=n
      proof
        defpred P[set] means s2.$1<>x0 & for m holds F.m<>$1;
        assume ex n st P[n];
        then
A25:    ex n be Nat st P[n];
        consider M1 be Nat such that
A26:    P[M1] & for n be Nat st P[n] holds M1<=n from NAT_1:sch 5(A25
        );
        defpred E[Nat] means $1<M1 & s2.$1<>x0 & ex m st F.m=$1;
A27:    ex n being Nat st E[n]
        proof
          take M;
          M<=M1 & M <> M1 by A14,A20,A26;
          hence M<M1 by XXREAL_0:1;
          thus s2.M<>x0 by A14;
          take 0;
          thus thesis by A20;
        end;
A28:    for n being Nat st E[n] holds n <= M1;
        consider MX be Nat such that
A29:    E[MX] & for n being Nat st E[n] holds n<=MX from NAT_1:sch 6(
        A28,A27 );
A30:    for k st MX<k & k<M1 holds s2.k=x0
        proof
          given k such that
A31:      MX<k and
A32:      k<M1 & s2.k<>x0;
          now
            per cases;
            suppose
              ex m st F.m=k;
              hence contradiction by A29,A31,A32;
            end;
            suppose
              for m holds F.m<>k;
              hence contradiction by A26,A32;
            end;
          end;
          hence contradiction;
        end;
        consider m such that
A33:    F.m=MX by A29;
A34:    MX<F.(m+1) & s2.(F.(m+1))<>x0 by A20,A33;
A35:    F.(m+1)<=M1 by A20,A26,A29,A33;
        now
          assume F.(m+1)<>M1;
          then F.(m+1)<M1 by A35,XXREAL_0:1;
          hence contradiction by A30,A34;
        end;
        hence contradiction by A26;
      end;
      defpred P[Nat] means (s2*F).$1<>x0;
A36:  for k st P[k] holds P[k+1]
      proof
        let k such that
        (s2*F).k<>x0;
        P2[F.k,F.(k+1)] by A20;
        then s2.(F.(k+1))<>x0;
        hence thesis by FUNCT_2:15;
      end;
A37:  P[0] by A14,A20,FUNCT_2:15;
A38:  for n holds P[n] from NAT_1:sch 2(A37,A36);
A39:  rng (s2*F) c= rng s2 by A22,VALUED_0:21;
      then rng (s2*F) c= dom f by A3;
      then
A40:  f/*(s2*F) is convergent & f/.x0=lim(f/*(s2*F)) by A2,A38,A23;
A41:  now
        let p;
        assume
A42:    0<p;
        then consider n such that
A43:    for m st n<=m holds |.(f/*(s2*F)).m-f/.x0.|<p by A40,COMSEQ_2:def 6;
         reconsider k=F.n as Nat;
        take k;
        let m such that
A44:    k<=m;
          per cases;
          suppose
A45:         s2.m=x0;
            m in NAT by ORDINAL1:def 12;
            then |.(f/*s2).m-f/.x0.|=|.f/.x0-f/.x0.| by A3,FUNCT_2:109,A45
              .=0 by COMPLEX1:44;
            hence |.(f/*s2).m-f/.x0.|<p by A42;
          end;
          suppose
            s2.m<>x0;
            then consider l be Nat such that
A46:        m=F.l by A24;
A47:      l in NAT by ORDINAL1:def 12;
A48:      m in NAT by ORDINAL1:def 12;
            n<=l by A44,A46,SEQM_3:1;
            then |.(f/*(s2*F)).l-f/.x0.|<p by A43;
            then |.f/.((s2*F).l)-f/.x0.|<p
              by A3,A39,FUNCT_2:109,XBOOLE_1:1,A47;
            then |.f/.(s2.m)-f/.x0.|<p by A46,FUNCT_2:15,A47;
            hence |.(f/*s2).m-f/.x0.|<p by A3,FUNCT_2:109,A48;
          end;
      end;
      hence f/*s2 is convergent;
      hence f/.x0=lim(f/*s2) by A41,COMSEQ_2:def 6;
    end;
  end;
  hence thesis;
end;
