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
  Z c= dom f & (for x st x in Z holds f/.x = a*x+b) implies f
  is_differentiable_on Z & for x st x in Z holds (f`|Z)/.x = a
proof
  reconsider cf = COMPLEX --> 0c as Function of COMPLEX,COMPLEX;
  set R = cf;
  now
    let h;
    now
      let n be Nat;
A2:   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 A2,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;
  assume that
A3: Z c= dom f and
A4: for x st x in Z holds f/.x = a*x+b;
  deffunc G(Complex) = In(a*$1,COMPLEX);
  consider L being Function of COMPLEX,COMPLEX such that
A5: for x being Element of COMPLEX holds L.x = G(x) from FUNCT_2:sch 4;
  for z holds L/.z = a*z
   proof let z;
     reconsider z as Element of COMPLEX by XCMPLX_0:def 2;
     L.z = G(z) by A5;
    hence thesis;
   end;
  then reconsider L as C_LinearFunc by Def4;
A6: now
    let x0;
    assume
A7: x0 in Z;
    then consider N being Neighbourhood of x0 such that
A8: N c= Z by Th9;
A9: for x st x in N holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0)
    proof
      let x;
A10: x - x0 in COMPLEX by XCMPLX_0:def 2;
      assume x in N;
      hence f/.x-f/.x0 = a*x+b-f/.x0 by A4,A8
        .= a*x+b-(a*x0+b) by A4,A7
        .= G(x-x0)+0c
        .= L/.(x-x0)+0c by A5,A10
        .= L/.(x-x0)+R/.(x-x0) by FUNCOP_1:7,A10;
    end;
    N c= dom f by A3,A8;
    hence f is_differentiable_in x0 by A9;
  end;
  hence
A11: f is_differentiable_on Z by A3,Th15;
  let x0;
  assume
A12: x0 in Z;
  then consider N being Neighbourhood of x0 such that
A13: N c= Z by Th9;
A14: for x st x in N holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0)
  proof
    let x;
A15: x - x0 in COMPLEX by XCMPLX_0:def 2;
    assume x in N;
    hence f/.x-f/.x0 = a*x+b-f/.x0 by A4,A13
      .= a*x+b-(a*x0+b) by A4,A12
      .= G(x-x0)+0c
      .= L/.(x-x0)+0c by A5,A15
      .= L/.(x-x0)+R/.(x-x0) by FUNCOP_1:7,A15;
  end;
A16: N c= dom f by A3,A13;
A17: f is_differentiable_in x0 by A6,A12;
  thus (f`|Z)/.x0 = diff(f,x0) by A11,A12,Def12
    .= L/.1r by A17,A16,A14,Def7
    .= G(1r) by A5
    .= a;
end;
