reserve x,x0, r,r1,r2 for Real,
      th for Real,

  rr for set,

  rseq for Real_Sequence;

theorem Th124:
  arccosec2 is_differentiable_on cosec.:].0,PI/2.[
proof
  set X = cosec.:].0,PI/2.[;
  set g1 = arccosec2|(cosec.:].0,PI/2.[);
  set f = cosec|].0,PI/2.];
  set g = f|].0,PI/2.[;
A1: g = cosec|].0,PI/2.[ by RELAT_1:74,XXREAL_1:21;
A2: dom ((g|].0,PI/2.[)") = rng (g|].0,PI/2.[) by FUNCT_1:33
    .= rng(cosec|].0,PI/2.[) by A1,RELAT_1:72
    .= cosec.:].0,PI/2.[ by RELAT_1:115;
A3: (g|].0,PI/2.[)" = (f|].0,PI/2.[)" by RELAT_1:72
    .= arccosec2|(f.:].0,PI/2.[) by RFUNCT_2:17
    .= arccosec2|(rng(f|].0,PI/2.[)) by RELAT_1:115
    .= arccosec2|(rng (cosec|].0,PI/2.[)) by RELAT_1:74,XXREAL_1:21
    .= arccosec2|(cosec.:].0,PI/2.[) by RELAT_1:115;
A4: g is_differentiable_on ].0,PI/2.[ by A1,Th8,FDIFF_2:16;
  now
A5: for x0 st x0 in ].0,PI/2.[ holds -cos.x0/(sin.x0)^2 < 0
    proof
      let x0;
      assume
A6:   x0 in ].0,PI/2.[;
      ].0,PI/2.[ c= ].-PI/2,PI/2.[ by XXREAL_1:46;
      then
A7:   cos.x0 > 0 by A6,COMPTRIG:11;
      ].0,PI/2.[ c= ].0,PI.[ by COMPTRIG:5,XXREAL_1:46;
      then sin.x0 > 0 by A6,COMPTRIG:7;
      hence thesis by A7;
    end;
    let x0 such that
A8: x0 in ].0,PI/2.[;
    diff(g,x0) = (g`|].0,PI/2.[).x0 by A4,A8,FDIFF_1:def 7
      .= ((cosec|].0,PI/2.[)`|].0,PI/2.[).x0 by RELAT_1:74,XXREAL_1:21
      .= (cosec`|].0,PI/2.[).x0 by Th8,FDIFF_2:16
      .= diff(cosec,x0) by A8,Th8,FDIFF_1:def 7
      .= -cos.x0/(sin.x0)^2 by A8,Th8;
    hence diff(g,x0) < 0 by A8,A5;
  end;
  then
A9: g1 is_differentiable_on X by A2,A4,A3,Lm24,FDIFF_2:48;
A10: for x st x in X holds arccosec2|X is_differentiable_in x
  proof
    let x;
    assume x in X;
    then g1|X is_differentiable_in x by A9,FDIFF_1:def 6;
    hence thesis by RELAT_1:72;
  end;
  X c= dom arccosec2 by A2,A3,RELAT_1:60;
  hence thesis by A10,FDIFF_1:def 6;
end;
