reserve x for object;
reserve x0,r,r1,r2,g,g1,g2,p,y0 for Real;
reserve n,m,k,l for Element of NAT;
reserve a,b,d for Real_Sequence;
reserve h,h1,h2 for non-zero 0-convergent Real_Sequence;
reserve c,c1 for constant Real_Sequence;
reserve A for open Subset of REAL;
reserve f,f1,f2 for PartFunc of REAL,REAL;
reserve L for LinearFunc;
reserve R for RestFunc;

theorem Th24:
  A c= dom f & (for r,p st r in A & p in A holds |.f.r - f.p.| <= (r - p)^2)
  implies f is_differentiable_on A &
  for x0 st x0 in A holds diff(f,x0) = 0
proof
  assume that
A1: A c= dom f and
A2: for r,p st r in A & p in A holds |.f.r - f.p.| <= (r - p)^2;
A3: now
    let x0;
    assume x0 in A;
    then consider N be Neighbourhood of x0 such that
A4: N c= A by RCOMP_1:18;
A5: N c= dom f by A1,A4;
    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)) = 0
    proof
      set a = seq_const 0;
      let h,c;
      assume that
A6:   rng c = {x0} and
A7:   rng (h + c) c= dom f;
A8:   lim (h + c) = x0 by A6,Th4;
      consider r be Real such that
A9:   0 < r and
A10:  N = ].x0 - r, x0 + r.[ by RCOMP_1:def 6;
      consider n being Nat such that
A11:  for m being Nat st n <= m holds |.(h + c).m - x0.| < r
        by A8,A9,SEQ_2:def 7;
      set hc = (h + c)^\n;
A12:  rng hc c= A
      proof
        let x be object;
        assume x in rng hc;
        then consider m such that
A13:    x = hc.m by FUNCT_2:113;
        x = (h + c).(m+n) by A13,NAT_1:def 3;
        then |.hc.m - x0.| < r by A11,A13,NAT_1:12;
        then x in N by A10,A13,RCOMP_1:1;
        hence thesis by A4;
      end;
A14:  rng c c= dom f
      proof
        let x be object;
        assume x in rng c;
        then
A15:    x = x0 by A6,TARSKI:def 1;
        x0 in N by RCOMP_1:16;
        hence thesis by A5,A15;
      end;
      set fn = (h"(#)(f/*(h+c) - f/*c))^\n;
      set h1 = h^\n;
      set c1 = c^\n;
A16:  rng c1 c= A
      proof
A17:    rng c1 c= rng c by VALUED_0:21;
        let x be object;
        assume x in rng c1;
        then
A18:    x = x0 by A6,A17,TARSKI:def 1;
        x0 in N by RCOMP_1:16;
        hence thesis by A4,A18;
      end;
A19:  abs(h1) is non-zero by SEQ_1:53;
A20:  for m being Nat holds a.m <= abs(fn).m & abs(fn).m <= |.h1.|.m
      proof
        let m be Nat;
A21:     m in NAT by ORDINAL1:def 12;
A22:    c1.m in rng c1 by VALUED_0:28;
        hc.m in rng hc by VALUED_0:28;
        then |.f.(hc.m) - f.(c1.m).| <= (hc.m - c1.m)^2 by A2,A12,A16,A22;
        then
A23:    |.f.(hc.m) - f.(c1.m).| <= |.hc.m - c1.m.|^2 by COMPLEX1:75;
A24:    (abs(h1).m)" * |.(f/*(h+c) - (f/*c))^\n.|.m = (abs(h1)").m * abs
        ((f/*(h+c) - f/*c)^\n).m by VALUED_1:10
          .= (abs(h1)" (#) abs((f/*(h+c) - f/*c)^\n)).m by SEQ_1:8
          .= (abs(h1") (#) abs((f/*(h+c) - f/*c)^\n)).m by SEQ_1:54
          .= |.h1" (#) ((f/*(h+c) - f/*c)^\n).|.m by SEQ_1:52
          .= |.(h")^\n (#) ((f/*(h+c) - f/*c)^\n).|.m by SEQM_3:18
          .= |.(h"(#)(f/*(h+c) - f/*c))^\n.|.m by SEQM_3:19;
        0 <= |. fn.m .| by COMPLEX1:46;
        then a.m <= |. fn.m .|;
        hence a.m <= abs(fn).m by SEQ_1:12;
A25:    |.hc.m - c1.m.|^2 = |.(h1 + c1).m - c1.m.|^2 by SEQM_3:15
          .= |.h1.m + c1.m - c1.m.|^2 by SEQ_1:7
          .= (abs(h1).m)^2 by SEQ_1:12
          .= abs(h1).m * abs(h1).m;
        0 <= |.h1.m.| by COMPLEX1:46;
        then
A26:    0 <= abs(h1).m by SEQ_1:12;
A27:    abs(h1).m <> 0 by A19,SEQ_1:5;
A28:    abs(h1).m * abs(h1).m * (abs(h1).m)" = abs(h1).m * (abs(h1).m * (
        abs(h1).m)")
          .= abs(h1).m * 1 by A27,XCMPLX_0:def 7
          .= abs(h1).m;
        |.f.(hc.m) - f.(c1.m).| = |.(f/*hc).m - f.(c1.m).| by A1,A12,
FUNCT_2:108,XBOOLE_1:1,A21
          .= |.(f/*hc).m - (f/*c1).m.| by A1,A16,FUNCT_2:108,XBOOLE_1:1,A21
          .= |.((f/*hc) - (f/*c1)).m.| by RFUNCT_2:1
          .= |.(f/*hc) - (f/*c1).|.m by SEQ_1:12
          .= |.(f/*(h+c))^\n - (f/*c1).|.m by A7,VALUED_0:27
          .= |.(f/*(h+c))^\n - ((f/*c)^\n).|.m by A14,VALUED_0:27
          .= |.(f/*(h+c) - (f/*c))^\n.|.m by SEQM_3:17;
        hence thesis by A23,A25,A26,A28,A24,XREAL_1:64;
      end;
      lim h1 = 0;
      then
A29:  lim abs(h1) = |.0.| by SEQ_4:14
        .= 0 by ABSVALUE:2;
A30:  lim a = a.0 by SEQ_4:26
        .= 0;
      then
A31:  lim abs(fn) = 0 by A29,A20,SEQ_2:20;
A32:  abs(fn) is convergent by A30,A29,A20,SEQ_2:19;
      then
A33:  fn is convergent by A31,SEQ_4:15;
      hence h"(#)(f/*(h+c) - f/*c) is convergent by SEQ_4:21;
      lim fn = 0 by A32,A31,SEQ_4:15;
      hence thesis by A33,SEQ_4:22;
    end;
    hence f is_differentiable_in x0 & diff(f,x0) = 0 by A5,Th12;
  end;
  then for x0 holds x0 in A implies f is_differentiable_in x0;
  hence f is_differentiable_on A by A1,FDIFF_1:9;
  let x0;
  assume x0 in A;
  hence thesis by A3;
end;
