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