reserve k, k1, n, n1, m for Nat;
reserve X, y for set;
reserve p for Real;
reserve r for Real;
reserve a, a1, a2, b, b1, b2, x, x0, z, z0 for Complex;
reserve s1, s3, seq, seq1 for Complex_Sequence;
reserve Y for Subset of COMPLEX;
reserve f, f1, f2 for PartFunc of COMPLEX,COMPLEX;
reserve Nseq for increasing sequence of NAT;
reserve h for 0-convergent non-zero Complex_Sequence;
reserve c for constant Complex_Sequence;
reserve R, R1, R2 for C_RestFunc;
reserve L, L1, L2 for C_LinearFunc;
reserve Z for open Subset of COMPLEX;

theorem
  for f,Z st Z c= dom f & f|Z = id Z holds f is_differentiable_on Z &
  for x st x in Z holds (f`|Z)/.x = 1r
proof
  reconsider cf = COMPLEX --> 0c as Function of COMPLEX,COMPLEX;
  set R = cf;
  reconsider L = id COMPLEX as PartFunc of COMPLEX,COMPLEX;
A1: COMPLEX c= COMPLEX;
  for b holds L/.b = 1r*b
   proof let b;
     b in COMPLEX by XCMPLX_0:def 2;
    hence thesis by A1,PARTFUN2:6;
   end;
  then reconsider L as C_LinearFunc by Def4;
  now
    let h;
    now
      let n be Nat;
A3:   n in NAT & rng h c= dom R by ORDINAL1:def 12;
      thus ((h")(#)(R/*h)).n = (h".n)*((R/*h).n) by VALUED_1:5
        .= (h").n*(R/.(h.n)) by A3,FUNCT_2:109
        .= (h".n)*0c
        .= 0c;
    end;
    then (h")(#)(R/*h) is constant & ((h")(#)(R/*h)).0 = 0c by VALUED_0:def 18;
    hence (h")(#)(R/*h) is convergent & lim ((h")(#)(R/*h)) = 0c by CFCONT_1:26
,27;
  end;
  then reconsider R as C_RestFunc by Def3;
  let f, Z;
  assume that
A4: Z c= dom f and
A5: f|Z = id Z;
A6: now
    let x be Complex;
    assume
A7: x in Z;
    then (f|Z).x = x by A5,FUNCT_1:18;
    then f.x = x by A7,FUNCT_1:49;
    hence f/.x = x by A4,A7,PARTFUN1:def 6;
  end;
A8: now
    let x0;
    assume
A9: x0 in Z;
    then consider N being Neighbourhood of x0 such that
A10: N c= Z by Th9;
A11: for x st x in N holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0)
    proof
      let x;
A12: x - x0 in COMPLEX by XCMPLX_0:def 2;
      assume x in N;
      hence f/.x-f/.x0 = x-f/.x0 by A6,A10
        .= x-x0 by A6,A9
        .= L/.(x-x0)+0c by A1,PARTFUN2:6,A12
        .= L/.(x-x0)+R/.(x-x0) by FUNCOP_1:7,A12;
    end;
    N c= dom f by A4,A10;
    hence f is_differentiable_in x0 by A11;
  end;
  hence
A13: f is_differentiable_on Z by A4,Th15;
  let x0;
  assume
A14: x0 in Z;
  then consider N1 being Neighbourhood of x0 such that
A15: N1 c= Z by Th9;
A16: f is_differentiable_in x0 by A8,A14;
  then ex N being Neighbourhood of x0 st N c= dom f & ex L,R st for x st x in
  N holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0);
  then consider N being Neighbourhood of x0 such that
A17: N c= dom f;
  consider N2 being Neighbourhood of x0 such that
A18: N2 c= N1 and
A19: N2 c= N by Lm1;
A20: N2 c= dom f by A17,A19;
A21: for x st x in N2 holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0)
  proof
    let x;
A22: x - x0 in COMPLEX by XCMPLX_0:def 2;
    assume x in N2;
    then x in N1 by A18;
    hence f/.x-f/.x0 = x-f/.x0 by A6,A15
      .= x-x0 by A6,A14
      .= L/.(x-x0)+0c by A1,PARTFUN2:6,A22
      .= L/.(x-x0)+R/.(x-x0) by FUNCOP_1:7,A22;
  end;
  thus (f`|Z)/.x0 = diff(f,x0) by A13,A14,Def12
    .= L/.1r by A16,A20,A21,Def7
    .= 1r;
end;
