
theorem Th15:
for f be PartFunc of REAL,REAL, I be non empty Interval st
 I c= dom f & inf I < sup I & (ex r be Real st rng f = {r}) holds
   f is_differentiable_on_interval I &
   for x be Real st x in I holds (f`\I).x = 0
proof
    let f be PartFunc of REAL,REAL, I be non empty Interval;
    assume that
A1:  I c= dom f and
A2:  inf I < sup I and
A3:  ex r be Real st rng f = {r};

    consider r be Real such that
A4:  rng f = {r} by A3;

A5: now assume
A6:  inf I in I; then
A7:  inf I = lower_bound I by Lm5;
     consider e be Real such that
A8:   e > 0 & [.lower_bound I,lower_bound I+e.] c= I by A6,A2,Lm14;
A9:  e > 0 & [.lower_bound I,lower_bound I+e.] c= dom f by A8,A1;

A10:  for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {lower_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n > 0) holds
        h"(#)(f/*(h+c) - f/*c) is convergent
      & lim (h"(#)(f/*(h+c) - f/*c)) = 0
     proof
      let h be non-zero 0-convergent Real_Sequence,
       c be constant Real_Sequence;
      assume that
A11:   rng c = {lower_bound I} and
A12:   rng(h+c) c= dom f and
       for n be Nat holds h.n > 0;

A13:   for p be Real st 0 < p
       ex N be Nat st for k be Nat st N <= k holds
        |. (h"(#)(f/*(h+c) - f/*c)).k - 0 .| < p
      proof
       let p be Real;
       assume
A14:    0 < p;
       take N=0;
       hereby let k be Nat;
        assume N <= k;

A15:    rng c c= I by A6,A7,A11,ZFMISC_1:31;

A16:    f/*c = f*c by A1,A6,A7,A11,ZFMISC_1:31,FUNCT_2:def 11;
A17:    f/*(h+c) = f*(h+c) by A12,FUNCT_2:def 11;

A18:    dom(h+c) = NAT & dom c = NAT by FUNCT_2:def 1; then
        k in dom(h+c) & k in dom c by ORDINAL1:def 12; then
        k in dom(f*(h+c)) & k in dom(f*c)
         by A12,A1,A6,A7,A11,ZFMISC_1:31,RELAT_1:27; then
        k in dom(f*(h+c)) /\ dom(f*c) by XBOOLE_0:def 4; then
A19:    k in dom(f*(h+c) - f*c) by VALUED_1:12;

        (h+c).k in rng(h+c) & c.k in rng c
          by A18,ORDINAL1:def 12,FUNCT_1:3; then
        f.((h+c).k) in rng f & f.(c.k) in rng f by A1,A12,A15,FUNCT_1:3; then
A20:    f.((h+c).k) = r & f.(c.k) = r by A4,TARSKI:def 1;

        (h"(#)(f/*(h+c) - f/*c)).k
         = (h").k * (f*(h+c) - f*c).k by A16,A17,VALUED_1:5
        .= (h").k * ((f*(h+c)).k - (f*c).k) by A19,VALUED_1:13
        .= (h").k * (f.((h+c).k) - (f*c).k) by A18,ORDINAL1:def 12,FUNCT_1:13
        .= (h").k * (f.((h+c).k) - f.(c.k)) by A18,ORDINAL1:def 12,FUNCT_1:13;
        hence |. (h"(#)(f/*(h+c) - f/*c)).k - 0 .| < p
         by A20,A14,COMPLEX1:44;
       end;
      end;
      hence h"(#)(f/*(h+c) - f/*c) is convergent by SEQ_2:def 6;
      hence lim(h"(#)(f/*(h+c) - f/*c)) = 0 by A13,SEQ_2:def 7;
     end; then
     for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {lower_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n > 0) holds
        h"(#)(f/*(h+c) - f/*c) is convergent;
     hence
A21:   f is_right_differentiable_in lower_bound I by A9,FDIFF_3:def 3;

     for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {lower_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n > 0) holds
        lim (h"(#)(f/*(h+c) - f/*c)) = 0 by A10;
     hence Rdiff(f,lower_bound I) = 0 by A21,FDIFF_3:def 6;
    end;

A22: now assume
A23:  sup I in I; then
A24:  sup I = upper_bound I by Lm6;
     consider e be Real such that
A25:   e > 0 & [.upper_bound I-e,upper_bound I.] c= I by A23,A2,Lm15;
A26:  e > 0 & [.upper_bound I-e,upper_bound I.] c= dom f by A25,A1;

A27:  for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {upper_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n < 0) holds
        h"(#)(f/*(h+c) - f/*c) is convergent
      & lim (h"(#)(f/*(h+c) - f/*c)) = 0
     proof
      let h be non-zero 0-convergent Real_Sequence,
       c be constant Real_Sequence;
      assume that
A28:   rng c = {upper_bound I} and
A29:   rng(h+c) c= dom f and
       for n be Nat holds h.n < 0;

A30:   for p be Real st 0 < p
       ex N be Nat st for k be Nat st N <= k holds
        |. (h"(#)(f/*(h+c) - f/*c)).k - 0 .| < p
      proof
       let p be Real;
       assume
A31:    0 < p;
       take N=0;
       hereby let k be Nat;
        assume N <= k;

A32:    rng c c= dom f by A1,A23,A24,A28,ZFMISC_1:31;

A33:    f/*c = f*c by A1,A23,A24,A28,ZFMISC_1:31,FUNCT_2:def 11;
A34:    f/*(h+c) = f*(h+c) by A29,FUNCT_2:def 11;

A35:    dom(h+c) = NAT & dom c = NAT by FUNCT_2:def 1; then
        k in dom(h+c) & k in dom c by ORDINAL1:def 12; then
        k in dom(f*(h+c)) & k in dom(f*c)
         by A29,A1,A23,A24,A28,ZFMISC_1:31,RELAT_1:27; then
        k in dom(f*(h+c)) /\ dom(f*c) by XBOOLE_0:def 4; then
A36:    k in dom(f*(h+c) - f*c) by VALUED_1:12;

        (h+c).k in rng(h+c) & c.k in rng c
          by A35,ORDINAL1:def 12,FUNCT_1:3; then
        f.((h+c).k) in rng f & f.(c.k) in rng f by A29,A32,FUNCT_1:3; then
A37:    f.((h+c).k) = r & f.(c.k) = r by A4,TARSKI:def 1;

        (h"(#)(f/*(h+c) - f/*c)).k
         = (h").k * (f*(h+c) - f*c).k by A33,A34,VALUED_1:5
        .= (h").k * ((f*(h+c)).k - (f*c).k) by A36,VALUED_1:13
        .= (h").k * (f.((h+c).k) - (f*c).k) by A35,ORDINAL1:def 12,FUNCT_1:13
        .= (h").k * (f.((h+c).k) - f.(c.k)) by A35,ORDINAL1:def 12,FUNCT_1:13;
        hence |. (h"(#)(f/*(h+c) - f/*c)).k - 0 .| < p
         by A37,A31,COMPLEX1:44;
       end;
      end;
      hence h"(#)(f/*(h+c) - f/*c) is convergent by SEQ_2:def 6;
      hence lim(h"(#)(f/*(h+c) - f/*c)) = 0 by A30,SEQ_2:def 7;
     end;
     then
     for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {upper_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n < 0) holds
        h"(#)(f/*(h+c) - f/*c) is convergent;

     hence
A38:   f is_left_differentiable_in upper_bound I by A26,FDIFF_3:def 4;

     for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {upper_bound I} & rng(h+c) c= dom f &
       (for n be Nat holds h.n < 0) holds
        lim (h"(#)(f/*(h+c) - f/*c)) = 0 by A27;
     hence Ldiff(f,upper_bound I) = 0 by A38,FDIFF_3:def 5;
    end;

    set J = ].inf I,sup I.[;

A39: J c= I by Lm13; then
A40: J c= dom f by A1; then
A41: dom(f|J) = J by RELAT_1:62;

    for x be Real st x in J holds f|J is_differentiable_in x
    proof
     let x be Real;
     assume
A42:   x in J; then
     inf I < x < sup I by XXREAL_1:4; then
     consider Z be open Subset of REAL such that
A43:   x in Z & Z c= J by Lm9;

     consider N be Neighbourhood of x such that
A44:   N c= Z by A43,RCOMP_1:18;
A45:  N c= dom(f|J) by A41,A43,A44;

     for h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence st
       rng c = {x} & rng(h+c) c= dom(f|J) holds
        h"(#)((f|J)/*(h+c)-(f|J)/*c) is convergent
     proof
      let h be non-zero 0-convergent Real_Sequence,
      c be constant Real_Sequence;
      assume that
A46:    rng c = {x} and
A47:    rng(h+c) c= dom(f|J);

      for p be Real st 0 < p
       ex N be Nat st for k be Nat st N <= k holds
        |. (h"(#)((f|J)/*(h+c) - (f|J)/*c)).k - 0 .| < p
      proof
       let p be Real;
       assume
A48:     0 < p;
       take N = 0;
       thus for k be Nat st N <= k holds
        |. (h"(#)((f|J)/*(h+c) - (f|J)/*c)).k - 0 .| < p
       proof
        let k be Nat;
        assume N <= k;

A49:    rng c c= dom(f|J) by A41,A42,A46,ZFMISC_1:31;

A50:    (f|J)/*(h+c) = (f|J)*(h+c) & (f|J)/*c = (f|J)*c
          by A47,A41,A42,A46,ZFMISC_1:31,FUNCT_2:def 11;

A51:    dom(h+c) = NAT & dom c = NAT by FUNCT_2:def 1; then
        k in dom(h+c) & k in dom c by ORDINAL1:def 12; then
        k in dom((f|J)*(h+c)) & k in dom((f|J)*c)
          by A47,A41,A42,A46,ZFMISC_1:31,RELAT_1:27; then
        k in dom((f|J)*(h+c)) /\ dom((f|J)*c) by XBOOLE_0:def 4; then
A52:    k in dom((f|J)*(h+c) - (f|J)*c) by VALUED_1:12;

A53:    (h+c).k in rng(h+c) & c.k in rng c
          by A51,ORDINAL1:def 12,FUNCT_1:3; then
A54:    (f|J).((h+c).k) = f.((h+c).k) & (f|J).(c.k) = f.(c.k)
          by A49,A47,FUNCT_1:47;

        dom(f|J) c= dom f by RELAT_1:60; then
        f.((h+c).k) in rng f & f.(c.k) in rng f by A53,A49,A47,FUNCT_1:3; then
A55:    f.((h+c).k) = r & f.(c.k) = r by A4,TARSKI:def 1;

        (h"(#)((f|J)/*(h+c) - (f|J)/*c)).k
         = (h").k * ((f|J)*(h+c) - (f|J)*c).k by A50,VALUED_1:5
        .= (h").k * (((f|J)*(h+c)).k - ((f|J)*c).k) by A52,VALUED_1:13
        .= (h").k * ((f|J).((h+c).k) - ((f|J)*c).k)
            by A51,ORDINAL1:def 12,FUNCT_1:13
        .= (h").k * ((f|J).((h+c).k) - (f|J).(c.k))
            by A51,ORDINAL1:def 12,FUNCT_1:13;
        hence |. (h"(#)((f|J)/*(h+c) - (f|J)/*c)).k - 0 .| < p
          by A48,A54,A55,COMPLEX1:44;
       end;
      end;
      hence h"(#)((f|J)/*(h+c)-(f|J)/*c) is convergent by SEQ_2:def 6;
     end;
     hence f|J is_differentiable_in x by A45,FDIFF_2:11;
    end; then
    f is_differentiable_on J by A40;
    hence
A56:  f is_differentiable_on_interval I by A1,A2,A5,A22;

    thus for x be Real st x in I holds (f`\I).x = 0
    proof
     let x be Real;
     assume A57: x in I;
     per cases;
     suppose A58: x = inf I; then
      x = lower_bound I by A57,Lm5;
      hence (f`\I).x = 0 by A56,A5,A57,A58,Def2;
     end;
     suppose A59: x = sup I; then
      x = upper_bound I by A57,Lm6;
      hence (f`\I).x = 0 by A56,A22,A57,A59,Def2;
     end;
     suppose A60: x <> inf I & x <> sup I; then
A61:   (f`\I).x = diff(f,x) by A56,A57,Def2;
      inf I <= x <= sup I by A57,XXREAL_2:61,62; then
      inf I < x < sup I by A60,XXREAL_0:1; then
      consider Z be open Subset of REAL such that
A62:    x in Z & Z c= ].inf I,sup I.[ by Lm9;
A63:   Z c= dom f by A1,A62,A39; then
A64:   f is_differentiable_on Z & for x be Real st x in Z holds (f`|Z).x = 0
        by A3,FDIFF_1:11;
      (f`|Z).x = 0 by A62,A63,A3,FDIFF_1:11;
      hence (f`\I).x = 0 by A61,A62,A64,FDIFF_1:def 7;
     end;
    end;
end;
