reserve x,a,b,c for Real,
  n for Nat,
  Z for open Subset of REAL,
  f, f1,f2 for PartFunc of REAL,REAL;

theorem
  not 0 in Z & Z c= dom (cosec*((id Z)^)) implies (cosec*((id Z)^))
is_differentiable_on Z & for x st x in Z holds ((cosec*((id Z)^))`|Z).x = cos.(
  1/x)/(x^2*(sin.(1/x))^2)
proof
  set f = id Z;
  assume that
A1: not 0 in Z and
A2: Z c= dom (cosec*(f^));
A3: f^ is_differentiable_on Z by A1,FDIFF_5:4;
  dom (cosec*(f^)) c= dom (f^) by RELAT_1:25;
  then
A4: Z c= dom (f^) by A2,XBOOLE_1:1;
A5: for x st x in Z holds (sin.((f^).x))<>0
  proof
    let x;
    assume x in Z;
    then f^.x in dom cosec by A2,FUNCT_1:11;
    hence thesis by RFUNCT_1:3;
  end;
A6: for x st x in Z holds cosec*(f^) is_differentiable_in x
  proof
    let x;
    assume
A7: x in Z;
    then (sin.((f^).x))<>0 by A5;
    then
A8: cosec is_differentiable_in (f^).x by Th2;
    f^ is_differentiable_in x by A3,A7,FDIFF_1:9;
    hence thesis by A8,FDIFF_2:13;
  end;
  then
A9: cosec*(f^) is_differentiable_on Z by A2,FDIFF_1:9;
  for x st x in Z holds ((cosec*(f^))`|Z).x = cos.(1/x)/(x^2*(sin.(1/x)) ^2)
  proof
    let x;
    assume
A10: x in Z;
    then
A11: f^ is_differentiable_in x by A3,FDIFF_1:9;
A12: sin.((f^).x)<>0 by A5,A10;
    then cosec is_differentiable_in (f^).x by Th2;
    then diff(cosec*(f^),x) = diff(cosec,(f^).x)*diff((f^),x) by A11,FDIFF_2:13
      .=(-cos.((f^).x)/(sin.((f^).x))^2) * diff((f^),x) by A12,Th2
      .=diff((f^),x)*(-cos.((f^).x)/(sin.((f.x)"))^2) by A4,A10,RFUNCT_1:def 2
      .=diff((f^),x)*(-cos.((f.x)")/(sin.((f.x)"))^2) by A4,A10,RFUNCT_1:def 2
      .=diff((f^),x)*(-cos.((f.x)")/(sin.(1*x"))^2) by A10,FUNCT_1:18
      .=diff((f^),x)*(-cos.(1*x")/(sin.(1*x"))^2) by A10,FUNCT_1:18
      .=((f^)`|Z).x*(-cos.(1*x")/(sin.(1*x"))^2) by A3,A10,FDIFF_1:def 7
      .=(-1/x^2)*(-cos.(1*x")/(sin.(1*x"))^2) by A1,A10,FDIFF_5:4
      .=(-1)/x^2*((-cos.(1/x))/(sin.(1/x))^2)
      .=(-1)*(-cos.(1/x))/(x^2*(sin.(1/x))^2) by XCMPLX_1:76
      .=cos.(1/x)/(x^2*(sin.(1/x))^2);
    hence thesis by A9,A10,FDIFF_1:def 7;
  end;
  hence thesis by A2,A6,FDIFF_1:9;
end;
