reserve n,m,k for Nat;
reserve x,X,X1 for set;
reserve r,p for Real;
reserve s,g,x0,x1,x2 for Real;
reserve S,T for RealNormSpace;
reserve f,f1,f2 for PartFunc of REAL,the carrier of S;
reserve s1,s2 for Real_Sequence;
reserve Y for Subset of REAL;

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