reserve n,m,k for Element of NAT;
reserve x, X,X1,Z,Z1 for set;
reserve s,g,r,p,x0,x1,x2 for Real;
reserve s1,s2,q1 for Real_Sequence;
reserve Y for Subset of REAL;
reserve f,f1,f2 for PartFunc of REAL,REAL;

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