reserve y for object, X for set;
reserve x,x0,x1,x2,g,g1,g2,r,r1,s,p,p1 for Real;
reserve n,m,k for Element of NAT;
reserve Y for Subset of REAL;
reserve Z for open Subset of REAL;
reserve s1,s3 for Real_Sequence;
reserve f,f1,f2 for PartFunc of REAL,REAL;
reserve h for non-zero 0-convergent Real_Sequence;
reserve c for constant Real_Sequence;
reserve R,R1,R2 for RestFunc;
reserve L,L1,L2 for LinearFunc;

theorem Th9:
  f is_differentiable_on Z iff Z c= dom f & for x st x in Z holds
  f is_differentiable_in x
proof
  thus f is_differentiable_on Z implies Z c=dom f & for x st x in Z holds f
  is_differentiable_in x
  proof
    assume
A1: f is_differentiable_on Z;
    hence Z c=dom f;
    let x0;
    assume
A2: x0 in Z;
    then f|Z is_differentiable_in x0 by A1;
    then consider N being Neighbourhood of x0 such that
A3: N c= dom(f|Z) and
A4: ex L,R st for x st x in N holds (f|Z).x-(f|Z).x0=L.(x-x0)+R.(x-x0);
    take N;
    dom(f|Z)=dom f/\Z by RELAT_1:61;
    then dom(f|Z) c=dom f by XBOOLE_1:17;
    hence N c= dom f by A3;
    consider L,R such that
A5: for x st x in N holds (f|Z).x - (f|Z).x0 = L.(x-x0) + R.(x-x0) by A4;
    take L,R;
    let x;
    assume
A6: x in N;
    then (f|Z).x-(f|Z).x0=L.(x-x0)+R.(x-x0) by A5;
    then f.x-(f|Z).x0=L.(x-x0)+R.(x-x0) by A3,A6,FUNCT_1:47;
    hence thesis by A2,FUNCT_1:49;
  end;
  assume that
A7: Z c=dom f and
A8: for x st x in Z holds f is_differentiable_in x;
  thus Z c=dom f by A7;
  let x0;
  assume
A9: x0 in Z;
  then consider N1 being Neighbourhood of x0 such that
A10: N1 c= Z by RCOMP_1:18;
  f is_differentiable_in x0 by A8,A9;
  then consider N being Neighbourhood of x0 such that
A11: N c= dom f and
A12: ex L,R st for x st x in N holds f.x-f.x0=L.(x-x0)+R.(x-x0);
  consider N2 being Neighbourhood of x0 such that
A13: N2 c= N1 and
A14: N2 c= N by RCOMP_1:17;
A15: N2 c= Z by A10,A13;
  take N2;
  N2 c= dom f by A11,A14;
  then N2 c= dom f/\Z by A15,XBOOLE_1:19;
  hence
A16: N2 c= dom(f|Z) by RELAT_1:61;
  consider L,R such that
A17: for x st x in N holds f.x-f.x0=L.(x-x0)+R.(x-x0) by A12;
A18: x0 in N2 by RCOMP_1:16;
  take L,R;
  let x;
  assume
A19: x in N2;
  then f.x-f.x0=L.(x-x0)+R.(x-x0) by A14,A17;
  then (f|Z).x-f.x0=L.(x-x0)+R.(x-x0) by A16,A19,FUNCT_1:47;
  hence thesis by A16,A18,FUNCT_1:47;
end;
