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
  Z c= dom (cosec*cot) implies cosec*cot is_differentiable_on Z & for x
  st x in Z holds ((cosec*cot)`|Z).x = cos.(cot.x)/(sin.x)^2/(sin.(cot.x))^2
proof
  assume
A1: Z c= dom (cosec*cot);
A2: for x st x in Z holds sin.(cot.x)<>0
  proof
    let x;
    assume x in Z;
    then cot.x in dom cosec by A1,FUNCT_1:11;
    hence thesis by RFUNCT_1:3;
  end;
  dom (cosec*cot) c= dom cot by RELAT_1:25;
  then
A3: Z c= dom cot by A1,XBOOLE_1:1;
A4: for x st x in Z holds cosec*cot is_differentiable_in x
  proof
    let x;
    assume
A5: x in Z;
    then sin.x<>0 by A3,FDIFF_8:2;
    then
A6: cot is_differentiable_in x by FDIFF_7:47;
    sin.(cot.x)<>0 by A2,A5;
    then cosec is_differentiable_in cot.x by Th2;
    hence thesis by A6,FDIFF_2:13;
  end;
  then
A7: cosec*cot is_differentiable_on Z by A1,FDIFF_1:9;
  for x st x in Z holds ((cosec*cot)`|Z).x = cos.(cot.x)/(sin.x)^2/(sin.(
  cot.x))^2
  proof
    let x;
    assume
A8: x in Z;
    then
A9: sin.x<>0 by A3,FDIFF_8:2;
    then
A10: cot is_differentiable_in x by FDIFF_7:47;
A11: sin.(cot.x)<>0 by A2,A8;
    then cosec is_differentiable_in cot.x by Th2;
    then diff(cosec*cot,x) = diff(cosec, cot.x)*diff(cot,x) by A10,FDIFF_2:13
      .=(-cos.(cot.x)/(sin.(cot.x))^2) * diff(cot,x) by A11,Th2
      .=(-1/(sin.x)^2)*(-cos.(cot.x)/(sin.(cot.x))^2) by A9,FDIFF_7:47
      .=cos.(cot.x)/(sin.x)^2/(sin.(cot.x))^2;
    hence thesis by A7,A8,FDIFF_1:def 7;
  end;
  hence thesis by A1,A4,FDIFF_1:9;
end;
