reserve r,r1,r2,g,g1,g2,x0,t for Real;
reserve n,k,m for Element of NAT;
reserve seq for Real_Sequence;
reserve f,f1,f2 for PartFunc of REAL,REAL;

theorem
  f is_left_convergent_in x0 & f is_right_convergent_in x0 & lim_left(f,
x0)=lim_right(f,x0) implies f is_convergent_in x0 & lim(f,x0)=lim_left(f,x0) &
  lim(f,x0)=lim_right(f,x0)
proof
  assume that
A1: f is_left_convergent_in x0 and
A2: f is_right_convergent_in x0 and
A3: lim_left(f,x0)=lim_right(f,x0);
A4: now
    let s be Real_Sequence such that
A5: s is convergent and
A6: lim s=x0 and
A7: rng s c=dom f\{x0};
    now
      per cases;
      suppose
        ex k st for n st k<=n holds s.n<x0;
        then consider k such that
A8:     for n st k<=n holds s.n<x0;
A9:     rng s c=dom f by A7,XBOOLE_1:1;
A10:    rng(s^\k)c=dom f/\left_open_halfline(x0)
        proof
          let x be object;
          assume x in rng(s^\k);
          then consider n such that
A11:      (s^\k).n=x by FUNCT_2:113;
          s.(n+k)<x0 by A8,NAT_1:12;
          then s.(n+k) in {g1: g1<x0};
          then s.(n+k) in left_open_halfline(x0) by XXREAL_1:229;
          then
A12:      x in left_open_halfline(x0) by A11,NAT_1:def 3;
          s.(n+k) in rng s by VALUED_0:28;
          then x in rng s by A11,NAT_1:def 3;
          hence thesis by A9,A12,XBOOLE_0:def 4;
        end;
A13:    f/*(s^\k) =(f/*s)^\k by A7,VALUED_0:27,XBOOLE_1:1;
A14:    lim(s^\k)=x0 by A5,A6,SEQ_4:20;
        then
A15:    f/*(s^\k) is convergent by A1,A3,A5,A10,LIMFUNC2:def 7;
        hence f/*s is convergent by A13,SEQ_4:21;
        lim(f/*(s^\k))=lim_left(f,x0) by A1,A5,A14,A10,LIMFUNC2:def 7;
        hence lim(f/*s)=lim_left(f,x0) by A15,A13,SEQ_4:22;
      end;
      suppose
A16:    for k ex n st k<=n & s.n>=x0;
        now
          per cases;
          suppose
            ex k st for n st k<=n holds x0<s.n;
            then consider k such that
A17:        for n st k<=n holds s.n>x0;
A18:        rng s c=dom f by A7,XBOOLE_1:1;
A19:        rng(s^\k)c=dom f/\right_open_halfline(x0)
            proof
              let x be object;
              assume x in rng(s^\k);
              then consider n such that
A20:          (s^\k).n=x by FUNCT_2:113;
              x0<s.(n+k) by A17,NAT_1:12;
              then s.(n+k) in {g1: x0<g1};
              then s.(n+k) in right_open_halfline(x0) by XXREAL_1:230;
              then
A21:          x in right_open_halfline(x0) by A20,NAT_1:def 3;
              s.(n+k) in rng s by VALUED_0:28;
              then x in rng s by A20,NAT_1:def 3;
              hence thesis by A18,A21,XBOOLE_0:def 4;
            end;
A22:        f/*(s^\k) =(f/*s)^\k by A7,VALUED_0:27,XBOOLE_1:1;
A23:        lim(s^\k)=x0 by A5,A6,SEQ_4:20;
            then
A24:        f/*(s^\k) is convergent by A2,A3,A5,A19,LIMFUNC2:def 8;
            hence f/*s is convergent by A22,SEQ_4:21;
            lim(f/*(s^\k))=lim_left(f,x0) by A2,A3,A5,A23,A19,LIMFUNC2:def 8;
            hence lim(f/*s)=lim_left(f,x0) by A24,A22,SEQ_4:22;
          end;
          suppose
A25:        for k ex n st k<=n & x0>=s.n;
            set GR=lim_left(f,x0);
            defpred P[set,set] means for n,m st $1=n & $2=m holds n<m & s.m<x0
            & for k st n<k & s.k<x0 holds m<=k;
            defpred X[Nat,set,set] means P[$2,$3];
            defpred X[Nat] means s.$1<x0;
A26:        now
              let k;
              consider n such that
A27:          k<=n and
A28:          s.n<=x0 by A25;
              take n;
              thus k<=n by A27;
              s.n in rng s by VALUED_0:28;
              then not s.n in {x0} by A7,XBOOLE_0:def 5;
              then s.n<>x0 by TARSKI:def 1;
              hence s.n<x0 by A28,XXREAL_0:1;
            end;
            then ex m1 be Element of NAT st 0<=m1 & s.m1<x0;
            then
A29:        ex m be Nat st X[m];
            consider M be Nat such that
A30:        X[M] & for n be Nat st X[n] holds M<=n from NAT_1:sch 5(
            A29);
            reconsider M9=M as Element of NAT by ORDINAL1:def 12;
A31:        now
              let n;
              consider m such that
A32:          n+1<=m and
A33:          s.m<x0 by A26;
              take m;
              thus n<m & s.m<x0 by A32,A33,NAT_1:13;
            end;
A34:        for n being Nat
             for x be Element of NAT ex y be Element of NAT st X[n,x ,y]
            proof
              let n be Nat;
              let x be Element of NAT;
              defpred X[Nat] means x<$1 & s.$1<x0;
              ex m st X[m] by A31;
              then
A35:          ex m be Nat st X[m];
              consider l be Nat such that
A36:          X[l] & for k be Nat st X[k] holds l<=k from NAT_1:sch 5
              (A35 );
              take l;
              l in NAT by ORDINAL1:def 12;
              hence thesis by A36;
            end;
            consider F be sequence of NAT such that
A37:        F.0=M9 & for n being Nat holds X[n,F.n,F.(n+1)] from RECDEF_1:sch 2
            (A34);
A38:        rng F c=NAT by RELAT_1:def 19;
            then
A39:        rng F c=REAL by NUMBERS:19;
A40:        dom F=NAT by FUNCT_2:def 1;
            then reconsider F as Real_Sequence by A39,RELSET_1:4;
A41:        now
              let n;
              F.n in rng F by A40,FUNCT_1:def 3;
              hence F.n is Element of NAT by A38;
            end;
            now
              let n be Nat;
A42:    n in NAT by ORDINAL1:def 12;
A43:          F.(n+1) is Element of NAT by A41;
              F.n is Element of NAT by A41,A42;
              hence F.n<F.(n+1) by A37,A43;
            end;
            then reconsider F as increasing sequence of NAT by SEQM_3:def 6;
A44:        s*F is subsequence of s by VALUED_0:def 17;
            then rng(s*F)c=rng s by VALUED_0:21;
            then
A45:        rng(s*F)c=dom f\{x0} by A7;
            defpred X[Nat] means s.$1<x0 & for m holds F.m<>$1;
A46:        for n st s.n<x0 ex m st F.m=n
            proof
              assume ex n st X[n];
              then
A47:          ex n be Nat st X[n];
              consider M1 be Nat such that
A48:          X[M1] & for n be Nat st X[n] holds M1<=n from NAT_1:sch
              5(A47 );
              defpred X[Nat] means $1<M1 & s.$1<x0 & ex m st F.m=$1;
A49:          ex n be Nat st X[n]
              proof
                take M;
A50:            M <> M1 by A37,A48;
                M<=M1 by A30,A48;
                hence M<M1 by A50,XXREAL_0:1;
                thus s.M<x0 by A30;
                take 0;
                thus thesis by A37;
              end;
A51:          for n be Nat st X[n] holds n<=M1;
              consider MX be Nat such that
A52:          X[MX] & for n be Nat st X[n] holds n<=MX from NAT_1:sch
              6(A51,A49);
A53:          for k st MX<k & k<M1 holds s.k>=x0
              proof
                given k such that
A54:            MX<k and
A55:            k<M1 and
A56:            s.k<x0;
                now
                  per cases;
                  suppose
                    ex m st F.m=k;
                    hence contradiction by A52,A54,A55,A56;
                  end;
                  suppose
                    for m holds F.m<>k;
                    hence contradiction by A48,A55,A56;
                  end;
                end;
                hence contradiction;
              end;
              consider m such that
A57:          F.m=MX by A52;
              M1 in NAT by ORDINAL1:def 12;
              then
A58:          F.(m+1)<=M1 by A37,A48,A52,A57;
A59:          s.(F.(m+1))<x0 by A37,A57;
A60:          MX<F.(m+1) by A37,A57;
              now
                assume F.(m+1)<>M1;
                then F.(m+1)<M1 by A58,XXREAL_0:1;
                hence contradiction by A53,A60,A59;
              end;
              hence contradiction by A48;
            end;
            defpred X[Nat] means s.$1>x0;
A61:        now
              let k;
              consider n such that
A62:          k<=n and
A63:          s.n>=x0 by A16;
              take n;
              thus k<=n by A62;
              s.n in rng s by VALUED_0:28;
              then not s.n in {x0} by A7,XBOOLE_0:def 5;
              then s.n<>x0 by TARSKI:def 1;
              hence s.n>x0 by A63,XXREAL_0:1;
            end;
            then ex mn be Element of NAT st 0<=mn & s.mn>x0;
            then
A64:        ex m be Nat st X[m];
            consider N be Nat such that
A65:        X[N] & for n be Nat st X[n] holds N<=n from NAT_1:sch 5(
            A64);
              defpred X[Nat] means (s*F).$1<x0;
A66:          for k being Nat st X[k] holds X[k+1]
              proof
                let k be Nat such that
                (s*F).k<x0;
                P[F.k,F.(k+1)] by A37;
                then s.(F.(k+1))<x0;
                hence thesis by FUNCT_2:15;
              end;
A67:          X[0] by A30,A37,FUNCT_2:15;
A68:        for k being Nat holds X[k] from NAT_1:sch 2(A67,A66);
A69:        rng(s*F)c=dom f/\left_open_halfline(x0)
            proof
              let x be object;
              assume
A70:          x in rng(s*F);
              then consider n such that
A71:          (s*F).n=x by FUNCT_2:113;
              (s*F).n<x0 by A68;
              then x in {g1: g1<x0} by A71;
              then
A72:          x in left_open_halfline(x0) by XXREAL_1:229;
              x in dom f by A45,A70,XBOOLE_0:def 5;
              hence thesis by A72,XBOOLE_0:def 4;
            end;
            defpred P[set,set] means for n,m st $1=n & $2=m holds n<m & s.m>x0
            & for k st n<k & s.k>x0 holds m<=k;
            defpred X[Nat,set,set] means P[$2,$3];
A73:        s*F is convergent by A5,A44,SEQ_4:16;
            reconsider N9=N as Element of NAT by ORDINAL1:def 12;
A74:        now
              let n;
              consider m such that
A75:          n+1<=m and
A76:          s.m>x0 by A61;
              take m;
              thus n<m & s.m>x0 by A75,A76,NAT_1:13;
            end;
A77:        for n being Nat
              for x be Element of NAT ex y be Element of NAT st X[n, x,y]
            proof
              let n be Nat;
              let x be Element of NAT;
              defpred X[Nat] means x<$1 & s.$1>x0;
              ex m st X[m] by A74;
              then
A78:          ex m be Nat st X[m];
              consider l be Nat such that
A79:          X[l] & for k be Nat st X[k] holds l<=k from NAT_1:sch
              5 (A78 );
              take l;
              l in NAT by ORDINAL1:def 12;
              hence thesis by A79;
            end;
            consider G be sequence of NAT such that
A80:        G.0=N9 & for n being Nat holds X[n,G.n,G.(n+1)] from RECDEF_1:sch
            2(A77);
A81:        rng G c=NAT by RELAT_1:def 19;
            then
A82:        rng G c=REAL by NUMBERS:19;
A83:        dom G=NAT by FUNCT_2:def 1;
            then reconsider G as Real_Sequence by A82,RELSET_1:4;
A84:        now
              let n;
              G.n in rng G by A83,FUNCT_1:def 3;
              hence G.n is Element of NAT by A81;
            end;
            now
              let n be Nat;
A85:    n in NAT by ORDINAL1:def 12;
A86:          G.(n+1) is Element of NAT by A84;
              G.n is Element of NAT by A84,A85;
              hence G.n<G.(n+1) by A80,A86;
            end;
            then reconsider G as increasing sequence of NAT by SEQM_3:def 6;
A87:        s*G is subsequence of s by VALUED_0:def 17;
            then rng(s*G)c=rng s by VALUED_0:21;
            then
A88:        rng(s*G)c=dom f\{x0} by A7;
A89:        lim(s*F)=x0 by A5,A6,A44,SEQ_4:17;
            then
A90:        lim(f/*(s*F))=lim_left(f,x0 ) by A1,A73,A69,LIMFUNC2:def 7;
A91:        f/*(s*F) is convergent by A1,A3,A73,A89,A69,LIMFUNC2:def 7;
A92:        s*G is convergent by A5,A87,SEQ_4:16;
            defpred X[Nat] means s.$1>x0 & for m holds G.m<>$1;
A93:        for n st s.n>x0 ex m st G.m=n
            proof
              assume ex n st X[n];
              then
A94:          ex n be Nat st X[n];
              consider N1 be Nat such that
A95:          X[N1] & for n be Nat st X[n] holds N1<=n from NAT_1:
              sch 5(A94 );
              defpred X[Nat] means $1<N1 & s.$1>x0 & ex m st G.m=$1;
A96:          ex n be Nat st X[n]
              proof
                take N;
A97:            N <> N1 by A80,A95;
                N<=N1 by A65,A95;
                hence N<N1 by A97,XXREAL_0:1;
                thus s.N>x0 by A65;
                take 0;
                thus thesis by A80;
              end;
A98:          for n be Nat st X[n] holds n<=N1;
              consider NX be Nat such that
A99:          X[NX] & for n be Nat st X[n] holds n<=NX from NAT_1:
              sch 6(A98,A96);
A100:          for k st NX<k & k<N1 holds s.k<=x0
              proof
                given k such that
A101:            NX<k and
A102:           k<N1 and
A103:           s.k>x0;
                now
                  per cases;
                  suppose
                    ex m st G.m=k;
                    hence contradiction by A99,A101,A102,A103;
                  end;
                  suppose
                    for m holds G.m<>k;
                    hence contradiction by A95,A102,A103;
                  end;
                end;
                hence contradiction;
              end;
              consider m such that
A104:         G.m=NX by A99;
              N1 in NAT by ORDINAL1:def 12;
              then
A105:         G.(m+1)<=N1 by A80,A95,A99,A104;
A106:         s.(G.(m+1))>x0 by A80,A104;
A107:         NX<G.(m+1) by A80,A104;
              now
                assume G.(m+1)<>N1;
                then G.(m+1)<N1 by A105,XXREAL_0:1;
                hence contradiction by A100,A107,A106;
              end;
              hence contradiction by A95;
            end;
              defpred X[Nat] means (s*G).$1>x0;
A108:         for k being Nat st X[k] holds X[k+1]
              proof
                let k be Nat such that
                (s*G).k>x0;
                P[G.k,G.(k+1)] by A80;
                then s.(G.(k+1))>x0;
                hence thesis by FUNCT_2:15;
              end;
A109:         X[0]by A65,A80,FUNCT_2:15;
A110:       for k being Nat holds X[k] from NAT_1:sch 2(A109,A108);
A111:       rng(s*G)c=dom f/\right_open_halfline(x0)
            proof
              let x be object;
              assume
A112:         x in rng(s*G);
              then consider n such that
A113:         (s*G).n=x by FUNCT_2:113;
              (s*G).n>x0 by A110;
              then x in {g1: x0<g1} by A113;
              then
A114:         x in right_open_halfline(x0) by XXREAL_1:230;
              x in dom f by A88,A112,XBOOLE_0:def 5;
              hence thesis by A114,XBOOLE_0:def 4;
            end;
A115:       lim(s*G)=x0 by A5,A6,A87,SEQ_4:17;
            then
A116:       lim(f/*(s*G))=lim_left(f,x0 ) by A2,A3,A92,A111,LIMFUNC2:def 8;
A117:       f/*(s*G) is convergent by A2,A3,A92,A115,A111,LIMFUNC2:def 8;
A118:       now
              let r be Real;
              assume
A119:         0<r;
              then consider n1 be Nat such that
A120:         for k being Nat st n1<=k holds |.(f/*(s*F)).k-GR.|<r
by A91,A90,
SEQ_2:def 7;
              consider n2 be Nat such that
A121:         for k being Nat st n2<=k holds |.(f/*(s*G)).k-GR.|<r
by A117,A116,A119,
SEQ_2:def 7;
               reconsider n=max(F.n1,G.n2) as Nat;
              take n;
              let k be Nat;
A122:    k in NAT by ORDINAL1:def 12;
              assume
A123:         n<=k;
              s.k in rng s by VALUED_0:28;
              then not s.k in {x0} by A7,XBOOLE_0:def 5;
              then
A124:         s.k<>x0 by TARSKI:def 1;
              now
                per cases by A124,XXREAL_0:1;
                suppose
                  s.k<x0;
                  then consider l be Element of NAT such that
A125:             k=F.l by A46,A122;
                  F.n1<=n by XXREAL_0:25;
                  then F.n1<=k by A123,XXREAL_0:2;
                  then l >= n1 by A125,SEQM_3:1;
                  then |.(f/*(s*F)).l-GR.|<r by A120;
                  then |.f.((s*F).l)-GR.|<r by A45,FUNCT_2:108,XBOOLE_1:1;
                  then |.f.(s.k)-GR.|<r by A125,FUNCT_2:15;
                  hence |.(f/*s).k-GR.|<r by A7,FUNCT_2:108,XBOOLE_1:1,A122;
                end;
                suppose
                  s.k>x0;
                  then consider l be Element of NAT such that
A126:             k=G.l by A93,A122;
                  G.n2<=n by XXREAL_0:25;
                  then G.n2<=k by A123,XXREAL_0:2;
                  then l >= n2 by A126,SEQM_3:1;
                  then |.(f/*(s*G)).l-GR.|<r by A121;
                  then |.f.((s*G).l)-GR.|<r by A88,FUNCT_2:108,XBOOLE_1:1;
                  then |.f.(s.k)-GR.|<r by A126,FUNCT_2:15;
                  hence |.(f/*s).k-GR.|<r by A7,FUNCT_2:108,XBOOLE_1:1,A122;
                end;
              end;
              hence |.(f/*s).k-GR.|<r;
            end;
            hence f/*s is convergent by SEQ_2:def 6;
            hence lim(f/*s)=lim_left(f,x0) by A118,SEQ_2:def 7;
          end;
        end;
        hence f/*s is convergent & lim(f/*s)=lim_left(f,x0);
      end;
    end;
    hence f/*s is convergent & lim(f/*s)=lim_left(f,x0);
  end;
  now
    let r1,r2;
    assume that
A127: r1<x0 and
A128: x0<r2;
    consider g1 such that
A129: r1<g1 and
A130: g1<x0 and
A131: g1 in dom f by A1,A127,LIMFUNC2:def 1;
    consider g2 such that
A132: g2<r2 and
A133: x0<g2 and
A134: g2 in dom f by A2,A128,LIMFUNC2:def 4;
    take g1;
    take g2;
    thus r1<g1 & g1<x0 & g1 in dom f & g2<r2 & x0<g2 & g2 in dom f by A129,A130
,A131,A132,A133,A134;
  end;
  hence f is_convergent_in x0 by A4;
  hence thesis by A3,A4,Def4;
end;
