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 (-cot-id Z) implies -cot-id Z is_differentiable_on Z & for x
  st x in Z holds ((-cot-id Z)`|Z).x=(cos.x)^2/(sin.x)^2
proof
  set f = -cot;
A1: for x st x in Z holds (id Z).x = 1*x+0 by FUNCT_1:18;
  assume
A2: Z c= dom (-cot-id Z);
  then
A3: Z c= dom (-cot) /\ dom (id Z) by VALUED_1:12;
  then
A4: Z c= dom (-cot) by XBOOLE_1:18;
  then
A5: Z c= dom cot by VALUED_1:8;
  for x st x in Z holds cot is_differentiable_in x
  proof
    let x;
    assume x in Z;
    then sin.x<>0 by A5,Th2;
    hence thesis by FDIFF_7:47;
  end;
  then
A6: cot is_differentiable_on Z by A5,FDIFF_1:9;
  then
A7: (-1)(#)cot is_differentiable_on Z by A4,FDIFF_1:20;
A8: Z c= dom (id Z) by A3,XBOOLE_1:18;
  then
A9: id Z is_differentiable_on Z by A1,FDIFF_1:23;
  for x st x in Z holds ((-cot-id Z)`|Z).x=(cos.x)^2/(sin.x)^2
  proof
    let x;
    assume
A10: x in Z;
    then
A11: sin.x<>0 by A5,Th2;
    then
A12: (sin.x)^2 >0 by SQUARE_1:12;
    ((f-id Z)`|Z).x=diff(f,x) - diff(id Z,x) by A2,A9,A7,A10,FDIFF_1:19
      .=(((-1)(#)cot)`|Z).x-diff(id Z,x) by A7,A10,FDIFF_1:def 7
      .=(-1)*diff(cot,x)-diff(id Z,x) by A4,A6,A10,FDIFF_1:20
      .=(-1)*(-1/(sin.x)^2)-diff(id Z,x) by A11,FDIFF_7:47
      .=1/(sin.x)^2-((id Z)`|Z).x by A9,A10,FDIFF_1:def 7
      .=1/(sin.x)^2-1 by A8,A1,A10,FDIFF_1:23
      .=1/(sin.x)^2-(sin.x)^2/(sin.x)^2 by A12,XCMPLX_1:60
      .=(1-(sin.x)^2)/(sin.x)^2
      .=((cos.x)^2+(sin.x)^2-(sin.x)^2)/(sin.x)^2 by SIN_COS:28
      .=(cos.x)^2/(sin.x)^2;
    hence thesis;
  end;
  hence thesis by A2,A9,A7,FDIFF_1:19;
end;
