reserve x,r,a,x0,p for Real;
reserve n,i,m for Element of NAT;
reserve Z for open Subset of REAL;
reserve f,f1,f2 for PartFunc of REAL,REAL;
reserve k for Nat;

theorem Th56:
  Z c= dom tan implies tan is_differentiable_on Z & tan`|Z = ((cos ^)^2)|Z
proof
  set f1 = cos^;
  assume
A1: Z c= dom tan;
A2: dom sin /\ dom f1 c=dom f1 by XBOOLE_1:17;
A3: dom(tan)=dom(sin(#)f1) by RFUNCT_1:31,SIN_COS:def 26
    .=dom sin /\ dom f1 by VALUED_1:def 4;
  then
A4: Z c=dom f1 by A1,A2;
A5: dom((cos^)(#)(cos^)) = dom (cos^) /\ dom (cos^) by VALUED_1:def 4
    .= dom (cos^);
  then
A6: dom(((cos^)(#)(cos^))|Z) = dom (cos^) /\ Z by RELAT_1:61
    .=Z by A1,A3,A2,XBOOLE_1:1,28;
A7: for x st x in Z holds tan is_differentiable_in x
  proof
    let x;
    assume x in Z;
    then
A8: cos.x <> 0 by A1,FDIFF_8:1;
    sin is_differentiable_in x & cos is_differentiable_in x by SIN_COS:63,64;
    hence thesis by A8,FDIFF_2:14,SIN_COS:def 26;
  end;
  then
A9: tan is_differentiable_on Z by A1,FDIFF_1:9;
A10: for x being Element of REAL
   st x in dom (tan`|Z) holds ((tan)`|Z).x = (((cos^)(#)(cos^))|Z).x
  proof
    let x be Element of REAL;
    assume x in dom (tan`|Z);
    then
A11: x in Z by A9,FDIFF_1:def 7;
    then
A12: cos.x <> 0 by A1,FDIFF_8:1;
    ((tan)`|Z).x=diff(sin/cos, x) by A9,A11,FDIFF_1:def 7,SIN_COS:def 26
      .=1/(cos.x)^2 by A12,FDIFF_7:46
      .=(1/cos.x)*(1/cos.x) by XCMPLX_1:102
      .=1*(cos.x)"*(1/cos.x) by XCMPLX_0:def 9
      .=cos^.x*(1/cos.x) by A4,A11,RFUNCT_1:def 2
      .=cos^.x*(1*(cos.x)") by XCMPLX_0:def 9
      .=cos^.x * f1.x by A4,A11,RFUNCT_1:def 2
      .=(cos^(#)f1).x by A4,A5,A11,VALUED_1:def 4
      .=((f1(#)f1)|Z).x by A11,FUNCT_1:49;
    hence thesis;
  end;
  dom (tan`|Z)=Z by A9,FDIFF_1:def 7;
  hence thesis by A1,A7,A6,A10,FDIFF_1:9,PARTFUN1:5;
end;
