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 Th22:
  for x0 be Complex for N being Neighbourhood of x0 st f
is_differentiable_in x0 & N c= dom f holds for h,c st rng c = {x0} & rng (h+c)
c= N holds h"(#)(f/*(h+c)-f/*c) is convergent & diff(f,x0) = lim (h"(#)(f/*(h+c
  )-f/*c))
proof
  let x0 be Complex;
  let N be Neighbourhood of x0;
  assume that
A1: f is_differentiable_in x0 and
A2: N c= dom f;
  consider N1 be Neighbourhood of x0 such that
  N1 c= dom f and
A3: ex L,R st for x st x in N1 holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0) by A1;
  consider N2 be Neighbourhood of x0 such that
A4: N2 c= N and
A5: N2 c= N1 by Lm1;
A6: N2 c= dom f by A2,A4;
  let h, c such that
A7: rng c = {x0} and
A8: rng (h+c) c= N;
  consider g be Real such that
A9: 0 < g and
A10: {y where y is Complex : |.y-x0.| < g} c= N2 by Def5;
  |.x0-x0.| = 0 by COMPLEX1:44;
  then x0 in {y where y is Complex : |.y-x0.| < g} by A9;
  then
A11: x0 in N2 by A10;
A12: rng c c= dom f
  proof
    let y be object;
    assume y in rng c;
    then y = x0 by A7,TARSKI:def 1;
    then y in N by A4,A11;
    hence thesis by A2;
  end;
  ex n st rng (c^\n) c= N2 & rng ((h+c)^\n) c= N2
  proof
    x0 in rng c by A7,TARSKI:def 1;
    then
A13: lim c = x0 by CFCONT_1:27;
A14: c is convergent by CFCONT_1:26;
    then
A15: h+c is convergent;
    lim h = 0 by Def1;
    then lim (h+c) = 0+x0 by A14,A13,COMSEQ_2:14
      .= x0;
    then consider n such that
A16: for m being Nat st n <= m holds |.(h+c).m-x0.| < g by A9,A15,
COMSEQ_2:def 6;
    take n;
A17: rng (c^\n) = {x0} by A7,VALUED_0:26;
    thus rng (c^\n) c= N2
    by A11,A17,TARSKI:def 1;
    let y be object;
    assume y in rng ((h+c)^\n);
    then consider m being Element of NAT such that
A18: y = ((h+c)^\n).m by FUNCT_2:113;
    reconsider y1 = y as Complex by A18;
    n+0 <= n+m by XREAL_1:7;
    then |.(h+c).(n+m)-x0.| < g by A16;
    then |.((h+c)^\n).m-x0.| < g by NAT_1:def 3;
    then y1 in {z where z is Complex : |.z-x0.| < g} by A18;
    hence thesis by A10;
  end;
  then consider n such that
  rng (c^\n) c= N2 and
A19: rng ((h+c)^\n) c= N2;
  consider L,R such that
A20: for x st x in N1 holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0) by A3;
A21: rng (c^\n) c= dom f
  proof
    let y be object;
    assume
A22: y in rng (c^\n);
    rng (c^\n) = rng c by VALUED_0:26;
    then y = x0 by A7,A22,TARSKI:def 1;
    then y in N by A4,A11;
    hence thesis by A2;
  end;
A23: (L/*(h^\n)+R/*(h^\n))(#)(h^\n)" is convergent & lim ((L/*(h^\n)+R/*(h^\
  n))(#)(h^\n)") = L/.1r
  proof
    deffunc F(Nat) = L/.1r+((R/*(h^\n))(#)(h^\n)").$1;
    consider s1 such that
A24: for k holds s1.k = F(k) from COMSEQ_1:sch 1;
A25: now
A26:  ((h^\n)")(#)(R/*(h^\n)) is convergent & lim (((h^\n)")(#)(R/*(h^\n)
      )) = 0 by Def3;
      let r be Real;
      assume 0 < r;
      then consider m being Nat such that
A27:  for k being Nat st m <= k
          holds |.(((h^\n)")(#)(R/*(h^\n))).k-0c.| < r
      by A26,COMSEQ_2:def 6;
      take n1 = m;
      let k such that
A28:  n1 <= k;
      |.s1.k-L/.1r.| = |.L/.1r+((R/*(h^\n))(#)(h^\n)").k-L/.1r .| by A24
        .= |.(((h^\n)")(#)(R/*(h^\n))).k-0c.|;
      hence |.s1.k-L/.1r.| < r by A27,A28;
    end;
    consider x such that
A29: for b1 holds L/.b1 = x*b1 by Def4;
A30: L/.1r = x*1r by A29
      .= x;
    now
      let m be Element of NAT;
A31:  (h^\n).m <> 0c by COMSEQ_1:4;
      thus ((L/*(h^\n)+R/*(h^\n))(#)(h^\n)").m = ((L/*(h^\n)+R/*(h^\n)).m)*((h
      ^\n)").m by VALUED_1:5
        .= ((L/*(h^\n)).m+(R/*(h^\n)).m) *((h^\n)").m by VALUED_1:1
        .= ((L/*(h^\n)).m)*((h^\n)").m+((R/*(h^\n)).m)*((h^\n)").m
        .= ((L/*(h^\n)).m)*((h^\n)").m+((R/*(h^\n))(#)(h^\n)").m by VALUED_1:5
        .= ((L/*(h^\n)).m)*((h^\n).m)"+((R/*(h^\n))(#)(h^\n)").m by VALUED_1:10
        .= (L/.((h^\n).m))*((h^\n).m)"+((R/*(h^\n))(#)(h^\n)").m by FUNCT_2:115
        .= (x*((h^\n).m))*((h^\n).m)"+((R/*(h^\n))(#)(h^\n)").m by A29
        .= x*(((h^\n).m)*((h^\n).m)")+((R/*(h^\n))(#)(h^\n)").m
        .= x*1r+((R/*(h^\n))(#)(h^\n)").m by A31,XCMPLX_0:def 7
        .= s1.m by A24,A30;
    end;
    then
A32: (L/*(h^\n)+R/*(h^\n))(#)(h^\n)" = s1;
    hence (L/*(h^\n)+R/*(h^\n))(#)(h^\n)" is convergent by A25;
    hence thesis by A32,A25,COMSEQ_2:def 6;
  end;
A33: for k holds f/.(((h+c)^\n).k)-f/.((c^\n).k) = L/.((h^\n).k)+R/.((h^\n). k)
  proof
    let k;
A34:  k+n in NAT by ORDINAL1:def 12;
A35:  k in NAT by ORDINAL1:def 12;
    then ((h+c)^\n).k in rng ((h+c)^\n) by FUNCT_2:112;
    then
A36: ((h+c)^\n).k in N2 by A19;
    (c^\n).k in rng (c^\n) & rng (c^\n) = rng c
        by FUNCT_2:112,VALUED_0:26,A35;
    then
A37: (c^\n).k = x0 by A7,TARSKI:def 1;
    ((h+c)^\n).k-(c^\n).k = (h+c).(k+n)-(c^\n).k by NAT_1:def 3
      .= h.(k+n)+c.(k+n)-(c^\n).k by VALUED_1:1,A34
      .= (h^\n).k+c.(k+n)-(c^\n).k by NAT_1:def 3
      .= (h^\n).k+(c^\n).k-(c^\n).k by NAT_1:def 3
      .= (h^\n).k;
    hence thesis by A20,A5,A36,A37;
  end;
A38: rng (h+c) c= dom f
  by A8,A2;
A39: rng ((h+c)^\n) c= dom f
  by A19,A4,A2;
  now
    let k be Element of NAT;
    thus (f/*((h+c)^\n)-f/*(c^\n)).k = (f/*((h+c)^\n)).k-(f/*(c^\n)).k by
CFCONT_1:1
      .= f/.(((h+c)^\n).k)-(f/*(c^\n)).k by A39,FUNCT_2:109
      .= f/.(((h+c)^\n).k)-f/.((c^\n).k) by A21,FUNCT_2:109
      .= L/.((h^\n).k)+R/.((h^\n).k) by A33
      .= (L/*(h^\n)).k+R/.((h^\n).k) by FUNCT_2:115
      .= (L/*(h^\n)).k+(R/*(h^\n)).k by FUNCT_2:115
      .= (L/*(h^\n)+R/*(h^\n)).k by VALUED_1:1;
  end;
  then
A40: ((L/*(h^\n)+R/*(h^\n))(#)(h^\n)") = ((f/*((h+c)^\n)-f/*(c^\n))(#)(h^\n)
  ") by FUNCT_2:def 7
    .= ((((f/*(h+c))^\n)-f/*(c^\n))(#)(h^\n)") by A38,VALUED_0:27
    .= ((((f/*(h+c))^\n)-((f/*c)^\n))(#)(h^\n)") by A12,VALUED_0:27
    .= ((((f/*(h+c))-(f/*c))^\n)(#)(h^\n)") by Th19
    .= ((((f/*(h+c))-(f/*c))^\n)(#)((h")^\n)) by Th20
    .= ((((f/*(h+c))-(f/*c))(#) h")^\n) by Th21;
  then
A41: L/.1r = lim ((h")(#)((f/*(h+c))-(f/*c))) by A23,CFCONT_1:23;
  thus h" (#) (f/*(h+c)-f/*c) is convergent by A23,A40,CFCONT_1:22;
  for x st x in N2 holds f/.x-f/.x0 = L/.(x-x0)+R/.(x-x0) by A20,A5;
  hence thesis by A1,A6,A41,Def7;
end;
