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
  for f be one-to-one PartFunc of REAL,REAL st [#]REAL c= dom f & f
  is_differentiable_on [#](REAL ) & ((for x0 holds 0 < diff(f,x0)) or for x0
holds diff(f,x0) < 0) holds f is one-to-one & f" is_differentiable_on dom (f")
  & for x0 st x0 in dom (f") holds diff(f",x0) = 1/diff(f,(f").x0)
proof
  let f be one-to-one PartFunc of REAL,REAL;
  assume that
 [#]REAL c= dom f and
A1: f is_differentiable_on [#](REAL) and
A2: (for x0 holds 0 < diff(f,x0)) or for x0 holds diff(f,x0) < 0;
A3: rng f is open by A1,A2,Th44;
  thus f is one-to-one;
A4: dom (f") = rng f by FUNCT_1:33;
A5: rng (f") = dom f by FUNCT_1:33;
A6: for y0 being Element of REAL st y0 in dom (f")
holds f" is_differentiable_in y0 &
  diff(f",y0) = 1/diff(f,(f").y0)
  proof
    let y0 be Element of REAL;
    assume
A7: y0 in dom (f");
    then consider x0 being Element of REAL such that
A8: x0 in dom f and
A9: y0 = f.x0 by A4,PARTFUN1:3;
A10: for h,c st rng c = {y0} & rng (h + c) c= dom (f") holds h"(#)((f")/*(
h+c) - (f")/*c) is convergent & lim (h"(#)((f")/*(h+c) - (f")/*c)) = 1/diff(f,(
    f").y0)
    proof
      reconsider fy =  (f").y0 as Element of REAL by XREAL_0:def 1;
      set a = seq_const (f").y0;
      let h,c such that
A11:  rng c = {y0} and
A12:  rng (h + c) c= dom (f");
A13:  lim (h + c) = y0 by A11,Th4;
      reconsider a as constant Real_Sequence;
      defpred P[Element of NAT,Real] means for r1,r2 be Real st
      r1=(h + c).$1 & r2 = a.$1 holds r1 = f.(r2 + $2);
A14:  for n ex r be Element of REAL st P[n,r]
      proof
        let n;
        (h + c).n in rng (h + c) by VALUED_0:28;
        then consider g being Element of REAL such that
        g in dom f and
A15:    (h + c).n = f.g by A4,A12,PARTFUN1:3;
        take r = g - x0;
        let r1,r2 be Real;
        assume that
A16:    r1 = (h + c).n and
A17:    r2 = a.n;
        a.n = (f").(f.x0) by A9,SEQ_1:57
          .= x0 by A8,FUNCT_1:34;
        hence r1 = f.(r2 + r) by A15,A16,A17;
      end;
      consider b such that
A18:  for n holds P[n,b.n] from FUNCT_2:sch 3(A14);
A19:  now
        let n;
        c.n in rng c by VALUED_0:28;
        hence c.n = f.x0 by A9,A11,TARSKI:def 1;
      end;
      now
        given n being Nat such that
A20:    b.n = 0;
A21:     n in NAT by ORDINAL1:def 12;
A22:    (h + c).n = h.n + c.n by SEQ_1:7
          .= h.n + f.x0 by A19,A21;
        f.(a.n + b.n) = f.((f").(f.x0)) by A9,A20,SEQ_1:57
          .= f.x0 by A8,FUNCT_1:34;
        then h.n + f.x0 = f.x0 by A18,A22,A21;
        hence contradiction by SEQ_1:5;
      end;
      then
A23:  b is non-zero by SEQ_1:5;
A24:  [#](REAL) c= dom f by A1;
      then dom f = REAL;
      then
A25:  f is total by PARTFUN1:def 2;
A26:  y0 in dom(f"|rng f) by A4,A7,RELAT_1:69;
      f|[#]REAL is increasing or f|[#]REAL is decreasing by A1,A2,Th37,Th38;
      then f"|rng f is continuous by A25,FCONT_3:22;
      then (f")|dom(f") is_continuous_in y0 by A4,A26,FCONT_1:def 2;
      then
A27:  f" is_continuous_in y0 by RELAT_1:68;
A28:  now
        let n;
A29:    b.n + a.n in [#] REAL;
        thus (((f")/*(h+c)) - a).n = ((f")/*(h+c)).n - a.n by RFUNCT_2:1
          .= (f").((h + c).n) - a.n by A12,FUNCT_2:108
          .= (f").(f.(b.n + a.n)) - a.n by A18
          .= b.n + a.n - a.n by A24,A29,FUNCT_1:34
          .= b.n;
      end;
A30:  (f")/*(h+c) is convergent by A12,A13,A27,FCONT_1:def 1;
      then ((f")/*(h+c)) - a is convergent;
      then
A31:  b is convergent by A28,FUNCT_2:63;
A32:  lim a = a.0 by SEQ_4:26
        .= (f").y0 by SEQ_1:57;
      (f").y0 = lim ((f")/*(h+c)) by A12,A13,A27,FCONT_1:def 1;
      then lim (((f")/*(h+c)) - a) = (f").y0 - (f").y0 by A30,A32,SEQ_2:12
        .= 0;
      then
A33:  lim b = 0 by A28,FUNCT_2:63;
A34:  rng (b + a) c= dom f
      by A24;
      reconsider b as 0-convergent non-zero Real_Sequence by A23,A31,A33,
FDIFF_1:def 1;
A35:  b" is non-zero by SEQ_1:33;
A36:  rng a = {(f").y0}
      proof
        thus rng a c= {(f").y0}
        proof
          let x be object;
          assume x in rng a;
          then ex n st x = a.n by FUNCT_2:113;
          then x = (f").y0 by SEQ_1:57;
          hence thesis by TARSKI:def 1;
        end;
        let x be object;
        assume x in {(f").y0};
        then x = (f").y0 by TARSKI:def 1;
        then a.0 = x by SEQ_1:57;
        hence thesis by VALUED_0:28;
      end;
A37:  rng a c= dom f
      proof
        let x be object;
        assume x in rng a;
        then x = (f").y0 by A36,TARSKI:def 1;
        hence thesis by A5,A7,FUNCT_1:def 3;
      end;
      now
        let n;
        c.n in rng c by VALUED_0:28;
        then
A38:    c.n = y0 by A11,TARSKI:def 1;
        thus (f/*a).n = f.(a.n) by A37,FUNCT_2:108
          .= f.((f").y0) by SEQ_1:57
          .= c.n by A4,A7,A38,FUNCT_1:35;
      end;
      then
A39:  f/*a = c;
      now
        let n;
        (h + c).n = f.(a.n + b.n) by A18;
        then h.n + c.n = f.(a.n + b.n) by SEQ_1:7;
        hence h.n = f.(b.n + a.n) - (f/*a).n by A39
          .= f.((b + a).n) - (f/*a).n by SEQ_1:7
          .= (f/*(b+a)).n - (f/*a).n by A34,FUNCT_2:108
          .= (f/*(b+a) - f/*a).n by RFUNCT_2:1;
      end;
      then
A40:  h = f/*(b+a) - f/*a;
      then f/*(b+a) - f/*a is non-zero;
      then
A41:  b"(#)(f/*(b+a) - f/*a) is non-zero by A35,SEQ_1:35;
A42:  rng c c= dom (f")
      by A7,A11,TARSKI:def 1;
      now
        let n;
A43:    a.n + b.n in [#] REAL;
        c.n in rng c by VALUED_0:28;
        then
A44:    c.n = y0 by A11,TARSKI:def 1;
        thus (h"(#)((f")/*(h+c) - (f")/*c)).n = (h").n * ((f")/*(h+c) - (f")/*
        c).n by SEQ_1:8
          .= (h").n * (((f")/*(h+c)).n - ((f")/*c).n) by RFUNCT_2:1
          .= (h").n * ((f").((h + c).n) - ((f")/*c).n) by A12,FUNCT_2:108
          .= (h").n * ((f").(f.(a.n + b.n)) - ((f")/*c).n) by A18
          .= (h").n * (a.n + b.n - ((f")/*c).n) by A24,A43,FUNCT_1:34
          .= (h").n * (a.n + b.n - (f").(c.n)) by A42,FUNCT_2:108
          .= (h").n * (a.n + b.n - a.n) by A44,SEQ_1:57
          .= (h" (#) (b"")).n by SEQ_1:8
          .= ((b" (#) (f/*(b+a) - f/*a))").n by A40,SEQ_1:36;
      end;
      then
A45:  h"(#)((f")/*(h+c) - (f")/*c) = (b"(#) (f/*(b+a) - f/*a))";
A46:  f is_differentiable_in fy by A1,FDIFF_1:9;
      then
A47:  lim (b"(#)(f/*(b+a) - f/*a)) = diff(f,(f").y0) by A36,A34,Th12;
      diff(f,(f").y0) = diff(f,(f").y0);
      then
A48:  b"(#)(f/*(b+a) - f/*a) is convergent by A36,A34,A46,Th12;
A49:  0 <> diff(f,(f").y0) by A2;
      hence h"(#)((f")/*(h+c) - (f")/*c) is convergent by A45,A41,A48,A47,
SEQ_2:21;
      thus lim (h"(#)((f")/*(h+c) - (f")/*c)) = diff(f,(f").y0)" by A45,A41,A48
,A47,A49,SEQ_2:22
        .= 1/diff(f,(f").y0) by XCMPLX_1:215;
    end;
    ex N being Neighbourhood of y0 st N c= dom (f") by A3,A4,A7,RCOMP_1:18;
    hence thesis by A10,Th12;
  end;
  then for y0 holds y0 in dom (f") implies f" is_differentiable_in
  y0;
  hence f" is_differentiable_on dom (f") by A3,A4,FDIFF_1:9;
  let x0;
  assume x0 in dom (f");
  hence thesis by A6;
end;
