reserve h,h1,h2 for 0-convergent non-zero Real_Sequence,
  c,c1 for constant Real_Sequence,
  f,f1,f2 for PartFunc of REAL,REAL,
  x0,r,r0,r1,r2,g,g1,g2 for Real,
  n0,k,n,m for Element of NAT,
  a,b,d for Real_Sequence,
  x for set;

theorem
  f is_right_differentiable_in x0 & f is_left_differentiable_in x0 &
Rdiff(f,x0) = Ldiff(f,x0) implies f is_differentiable_in x0 & diff(f,x0)=Rdiff(
  f,x0) & diff(f,x0)=Ldiff(f,x0)
proof
  assume that
A1: f is_right_differentiable_in x0 and
A2: f is_left_differentiable_in x0 and
A3: Rdiff(f,x0) = Ldiff(f,x0);
A4: ex N being Neighbourhood of x0 st N c= dom f
  proof
    consider r2 such that
A5: r2>0 and
A6: [.x0,x0+r2.] c= dom f by A1;
    consider r1 such that
A7: r1>0 and
A8: [.x0-r1,x0.] c= dom f by A2;
    set r = min(r1,r2);
    r > 0 by A7,A5,XXREAL_0:15;
    then reconsider N = ].x0 -r,x0+r.[ as Neighbourhood of x0 by RCOMP_1:def 6;
    take N;
    let x be object;
    assume x in N;
    then x in { g: x0 - r < g & g < x0 + r} by RCOMP_1:def 2;
    then consider g such that
A9: g = x and
A10: x0 - r < g and
A11: g < x0 + r;
    now
      per cases;
      suppose
A12:    g <= x0;
        r <= r1 by XXREAL_0:17;
        then x0 - r1 <= x0 - r by XREAL_1:13;
        then x0 - r1 <= g by A10,XXREAL_0:2;
        then g in {g1: x0 - r1 <= g1 & g1 <= x0} by A12;
        then g in [.x0-r1,x0.] by RCOMP_1:def 1;
        hence thesis by A8,A9;
      end;
      suppose
A13:    g > x0;
        r <= r2 by XXREAL_0:17;
        then x0 + r <= x0 + r2 by XREAL_1:7;
        then g <= x0 + r2 by A11,XXREAL_0:2;
        then g in {g1: x0 <= g1 & g1 <= x0+r2} by A13;
        then g in [.x0,x0+r2.] by RCOMP_1:def 1;
        hence thesis by A6,A9;
      end;
    end;
    hence thesis;
  end;
  for h,c st rng c = {x0} & rng (h + c) c= dom f holds h"(#)(f/*(h+c) - f
  /*c) is convergent & lim (h"(#) (f/*(h+c) - f/*c)) = Ldiff(f,x0)
  proof
    let h,c;
    assume that
A14: rng c = {x0} and
A15: rng (h + c) c= dom f;
A16: rng c c= dom f
    proof
      consider S being Neighbourhood of x0 such that
A17:  S c= dom f by A4;
      x0 in S by RCOMP_1:16;
      hence thesis by A14,A17,ZFMISC_1:31;
    end;
    now
      per cases;
      suppose
        ex N be Element of NAT st for n st n >= N holds h.n > 0;
        then consider N be Element of NAT such that
A18:    for n st n >= N holds h.n > 0;
        set h1 = h ^\N;
A19:    for n being Nat holds h1.n > 0
        proof
          let n be Nat;
          h1.n = h.(n+N) & N + 0 <= n + N by NAT_1:def 3,XREAL_1:7;
          hence thesis by A18;
        end;
        set c1 = c ^\N;
A20:    rng c1 = {x0}
        proof
          thus rng c1 c= {x0} by A14,VALUED_0:21;
          let x be object;
A21:      c.N in rng c by VALUED_0:28;
          assume x in {x0};
          then
A22:      x = x0 by TARSKI:def 1;
          c1.0 = c.(0+N) by NAT_1:def 3
            .= c.N;
          then c1.0 = x by A14,A22,A21,TARSKI:def 1;
          hence thesis by VALUED_0:28;
        end;
A23:    h1 + c1 = (h + c)^\N by SEQM_3:15;
        then
A24:    h1"(#)(f/*(h1+c1) - f/*c1) = h1"(#)((f/*(h+c))^\N - f/*c1) by A15,
VALUED_0:27
          .= h1"(#)((f/*(h+c))^\N - (f/*c)^\N) by A16,VALUED_0:27
          .= h1"(#)((f/*(h+c) - f/*c)^\N) by SEQM_3:17
          .= ((h")^\N) (#)((f/*(h+c) - f/*c)^\N) by SEQM_3:18
          .= (h"(#)(f/*(h+c) - f/*c))^\N by SEQM_3:19;
        rng (h1 + c1) c= rng (h + c) by A23,VALUED_0:21;
        then
A25:    rng (h1 + c1) c= dom f by A15;
        then
A26:    h1"(#)(f/*(h1+c1) - f/*c1) is convergent by A1,A20,A19;
        hence h"(#)(f/*(h+c) - f/*c) is convergent by A24,SEQ_4:21;
        lim (h1"(#)(f/*(h1+c1) - f/*c1)) = Rdiff(f,x0) by A1,A20,A25,A19,Th15;
        hence lim (h"(#)(f/*(h+c) - f/*c)) =Ldiff(f,x0) by A3,A26,A24,SEQ_4:22;
      end;
      suppose
A27:    for N be Element of NAT ex n st n >= N & h.n <= 0;
        now
          per cases;
          suppose
            ex M be Element of NAT st for m st m >= M holds h.m < 0;
            then consider M be Element of NAT such that
A28:        for n st n >= M holds h.n < 0;
            set h1 = h ^\M;
A29:        for n being Nat holds h1.n < 0
            proof
              let n be Nat;
              h1.n = h.(n+M) & M + 0 <= n + M by NAT_1:def 3,XREAL_1:7;
              hence thesis by A28;
            end;
            set c1 = c ^\M;
A30:        rng c1 = {x0}
            proof
              thus rng c1 c= {x0} by A14,VALUED_0:21;
              let x be object;
A31:          c.M in rng c by VALUED_0:28;
              assume x in {x0};
              then
A32:          x = x0 by TARSKI:def 1;
              c1.0 = c.(0+M) by NAT_1:def 3
                .= c.M;
              then c1.0 = x by A14,A32,A31,TARSKI:def 1;
              hence thesis by VALUED_0:28;
            end;
A33:        h1 + c1 = (h + c)^\M by SEQM_3:15;
            then
A34:        h1"(#)(f/*(h1+c1) - f/*c1) = h1"(#)((f/*(h+c))^\M - f/*c1) by A15,
VALUED_0:27
              .= h1"(#)((f/*(h+c))^\M - (f/*c)^\M) by A16,VALUED_0:27
              .= h1"(#)((f/*(h+c) - f/*c)^\M) by SEQM_3:17
              .= ((h")^\M) (#)((f/*(h+c) - f/*c)^\M) by SEQM_3:18
              .= (h"(#)(f/*(h+c) - f/*c))^\M by SEQM_3:19;
            rng (h1 + c1) c= rng (h + c) by A33,VALUED_0:21;
            then
A35:        rng (h1 + c1) c= dom f by A15;
            then
A36:        h1"(#)(f/*(h1+c1) - f/*c1) is convergent by A2,A30,A29;
            hence h"(#)(f/*(h+c) - f/*c) is convergent by A34,SEQ_4:21;
            lim (h1"(#)(f/*(h1+c1) - f/*c1)) = Ldiff(f,x0) by A2,A30,A35,A29
,Th9;
            hence lim (h"(#)(f/*(h+c) - f/*c)) =Ldiff(f,x0) by A36,A34,SEQ_4:22
;
          end;
          suppose
A37:        for M be Element of NAT ex m st m >= M & h.m >= 0;
            set s = (h")(#)(f/*(h+c)-f/*c);
            defpred R[Real] means $1 > 0;
            defpred P[Real] means $1 < 0;
A38:        for N be Element of NAT ex n st n >= N & P[h.n]
            proof
              let m;
              consider n such that
A39:          n >= m and
A40:          h.n <= 0 by A27;
              take n;
              thus n >= m by A39;
              h.n <> 0 by SEQ_1:5;
              hence thesis by A40;
            end;
            consider q1 being increasing sequence of NAT such that
A41:        (for n being Nat holds P[(h*q1).n]) &
             for n st (for r st r = h.n
            holds P[r]) ex m st n = q1.m from FDIFF_2:sch 1(A38);
A42:        for N be Element of NAT ex n st n >= N & R[h.n]
            proof
              let m;
              consider n such that
A43:          n >= m and
A44:          h.n >= 0 by A37;
              take n;
              thus n >= m by A43;
              h.n <> 0 by SEQ_1:5;
              hence thesis by A44;
            end;
            consider q2 being increasing sequence of NAT such that
A45:        (for n being Nat holds R[(h*q2).n]) &
            for n st (for r st r = h.n
            holds R[r]) ex m st n = q2.m from FDIFF_2:sch 1(A42);
            set h1 = h*q1;
            reconsider h1 as subsequence of h;
A46:        h1 is convergent by SEQ_4:16;
A47:        lim h = 0;
            then
A48:        lim h1 = 0 by SEQ_4:17;
            set h2 = h*q2;
A49:        h2 is convergent by SEQ_4:16;
            lim h2 = 0 by A47,SEQ_4:17;
            then reconsider h2 as 0-convergent non-zero Real_Sequence
              by A49,FDIFF_1:def 1;
            set c2 = c*q2;
A50:        rng c2 = {x0} by A14,VALUED_0:26;
            reconsider c2 as constant Real_Sequence;
            rng ((h+c)*q2) c= rng (h+c) by VALUED_0:21;
            then rng ((h+c)*q2) c= dom f by A15;
            then rng (h2+c2) c= dom f by RFUNCT_2:2;
            then
A51:        h2"(#)(f/*(h2+c2)-f/*c2) is convergent & lim(h2"(#)(f/*(h2+
            c2)-f/*c2))=Ldiff (f,x0) by A1,A3,A45,A50,Th15;
A52:        h2"(#)(f/*(h2+c2)-f/*c2) = h2"(#)(f/*((h+c)*q2)-f/*c2) by
RFUNCT_2:2
              .= h2"(#)(f/*(h+c)*q2-f/*c2) by A15,FUNCT_2:110
              .= ((h")*q2)(#)(f/*(h+c)*q2-f/*c2) by RFUNCT_2:5
              .= ((h")*q2)(#)(f/*(h+c)*q2-f/*c*q2) by A16,FUNCT_2:110
              .= ((h")*q2)(#)((f/*(h+c)-f/*c)*q2) by RFUNCT_2:2
              .= ((h")(#)(f/*(h+c)-f/*c))*q2 by RFUNCT_2:2;
            reconsider h1 as 0-convergent non-zero Real_Sequence
              by A46,A48,FDIFF_1:def 1;
            set c1 = c*q1;
A53:        rng c1 = {x0} by A14,VALUED_0:26;
            reconsider c1 as constant Real_Sequence;
            rng ((h+c)*q1) c= rng (h+c) by VALUED_0:21;
            then rng ((h+c)*q1) c= dom f by A15;
            then rng (h1+c1) c= dom f by RFUNCT_2:2;
            then
A54:        h1"(#)(f/*(h1+c1)-f/*c1) is convergent & lim(h1"(#)(f/*(h1+
            c1)-f/*c1))=Ldiff (f,x0) by A2,A41,A53,Th9;
A55:        h1"(#)(f/*(h1+c1)-f/*c1) = h1"(#)(f/*((h+c)*q1)-f/*c1) by
RFUNCT_2:2
              .= h1"(#)(f/*(h+c)*q1-f/*c1) by A15,FUNCT_2:110
              .= ((h")*q1)(#)(f/*(h+c)*q1-f/*c1) by RFUNCT_2:5
              .= ((h")*q1)(#)(f/*(h+c)*q1-f/*c*q1) by A16,FUNCT_2:110
              .= ((h")*q1)(#)((f/*(h+c)-f/*c)*q1) by RFUNCT_2:2
              .= ((h")(#)(f/*(h+c)-f/*c))*q1 by RFUNCT_2:2;
A56:        for g1 be Real st 0<g1
       ex n being Nat st for m being Nat st n<=m holds
            |.s.m - Ldiff(f,x0).|<g1
            proof
              let g1 be Real;
              assume
A57:          0 < g1;
              then consider n1 be Nat such that
A58:          for m being Nat st n1 <= m
holds |.(s*q1).m - Ldiff(f,x0).|<g1
              by A54,A55,SEQ_2:def 7;
              consider n2 be Nat such that
A59:          for m being Nat st n2 <= m
holds |.(s*q2).m - Ldiff(f,x0).|<g1
              by A51,A52,A57,SEQ_2:def 7;
              take n = max(q1.n1,q2.n2);
              let m being Nat such that
A60:          n <= m;
A61:           m in NAT by ORDINAL1:def 12;
A62:          n >= q2.n2 by XXREAL_0:25;
A63:          n >= q1.n1 by XXREAL_0:25;
                per cases;
                suppose
                  h.m > 0;
                  then for r st r = h.m holds r > 0;
                  then consider k such that
A64:              m = q2.k by A45,A61;
A65:         n2 in NAT by ORDINAL1:def 12;
                  dom q2 = NAT & q2.k >= q2.n2 by A60,A62,A64,FUNCT_2:def 1
,XXREAL_0:2;
                  then not k < n2 by VALUED_0:def 13,A65;
                  then |.(s*q2).k - Ldiff(f,x0).|<g1 by A59;
                  hence thesis by A64,FUNCT_2:15;
                end;
                suppose
A66:              h.m <= 0;
                  h.m <> 0 by SEQ_1:5;
                  then for r st r = h.m holds r < 0 by A66;
                  then consider k such that
A67:              m = q1.k by A41,A61;
A68:         n1 in NAT by ORDINAL1:def 12;
                  dom q1 = NAT & q1.k >= q1.n1 by A60,A63,A67,FUNCT_2:def 1
,XXREAL_0:2;
                  then not k < n1 by VALUED_0:def 13,A68;
                  then |.(s*q1).k - Ldiff(f,x0).|<g1 by A58;
                  hence thesis by A67,FUNCT_2:15;
                end;
              end;
            hence s is convergent by SEQ_2:def 6;
            hence lim s = Ldiff(f,x0) by A56,SEQ_2:def 7;
          end;
        end;
        hence thesis;
      end;
    end;
    hence thesis;
  end;
  hence thesis by A3,A4,FDIFF_2:12;
end;
