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 Th14:
  x in Z implies (diff(cos,Z).n).x = cos.(x + n*PI/2)
proof
  assume
A1: x in Z;
  dom(((-1)(#) sin)|Z) = dom((-1)(#) sin)/\ Z by RELAT_1:61
    .= dom(sin) /\ Z by VALUED_1:def 5
    .= Z by SIN_COS:24,XBOOLE_1:28;
  then
A2: Z c= dom((-1)(#) sin) by RELAT_1:60;
  dom(((-1)(#) cos)|Z) =dom((-1)(#) cos)/\ Z by RELAT_1:61
    .= dom(cos) /\ Z by VALUED_1:def 5
    .= Z by SIN_COS:24,XBOOLE_1:28;
  then
A3: Z c= dom((-1)(#) cos) by RELAT_1:60;
A4: cos is_differentiable_on Z by FDIFF_1:26,SIN_COS:67;
  then
A5: (-1)(#)cos is_differentiable_on Z by FDIFF_2:19;
A6: sin is_differentiable_on Z by FDIFF_1:26,SIN_COS:68;
  then
A7: (-1)(#)sin is_differentiable_on Z by FDIFF_2:19;
  per cases;
  suppose
    n>0;
    then 0<0+n;
    then 1<=n by NAT_1:19;
    then reconsider i=n-1 as Element of NAT by INT_1:5;
    now
      per cases;
      suppose
        i is even;
        then consider j be Nat such that
A8:     i = 2*j by ABIAN:def 2;
        per cases;
        suppose
          j is even;
          then consider m be Nat such that
A9:       j = 2*m by ABIAN:def 2;
          (diff(cos,Z).(i+1)).x = (diff(cos,Z).(2*j) `| Z).x by A8,
TAYLOR_1:def 5
            .=((-1) |^ (2*m) (#) cos | Z`| Z).x by A9,TAYLOR_2:19
            .=( 1 |^ (2*m) (#) cos | Z`| Z).x by WSIERP_1:2
            .= (1 (#) cos | Z`| Z).x
            .=(cos | Z`| Z).x by RFUNCT_1:21
            .=(cos`| Z).x by A4,FDIFF_2:16
            .=diff(cos,x) by A1,A4,FDIFF_1:def 7
            .=-sin.x by SIN_COS:63
            .=cos.(x+PI/2) by SIN_COS:78
            .=cos.(x+PI/2+(2*PI*m)) by SIN_COS2:11
            .=cos.(x+PI/2+((i/2)*PI)) by A8,A9
            .=cos.(x+n*PI/2);
          hence thesis;
        end;
        suppose
          j is odd;
          then consider s be Nat such that
A10:      j = 2*s+1 by ABIAN:9;
          (diff(cos,Z).(i+1)).x = (diff(cos,Z).(2*j) `| Z).x by A8,
TAYLOR_1:def 5
            .=((-1) |^ (2*s+1) (#) cos | Z`| Z).x by A10,TAYLOR_2:19
            .=(((-1) |^ (2*s)*(-1)) (#) cos | Z`| Z).x by NEWTON:6
            .=((1|^ (2*s)*(-1)) (#) cos | Z`| Z).x by WSIERP_1:2
            .=((1*(-1)) (#) cos | Z`| Z).x
            .=((-cos)| Z`| Z).x by RFUNCT_1:49
            .=(((-1) (#) cos)`| Z).x by A5,FDIFF_2:16
            .=(-1)*diff(cos,x) by A1,A3,A4,FDIFF_1:20
            .=(-1)*(-sin.x) by SIN_COS:63
            .=sin.(x+(2*PI*s)) by SIN_COS2:10
            .=sin.(x+((i/2-1)*PI)+2*PI) by A8,A10,SIN_COS:78
            .=cos.(PI/2-(x+(i/2+1)*PI)) by SIN_COS:78
            .=cos.(-(PI/2-(x+(i/2+1)*PI))) by SIN_COS:30
            .=cos.(x+n*PI/2);
          hence thesis;
        end;
      end;
      suppose
        i is odd;
        then consider j be Nat such that
A11:    i = 2*j +1 by ABIAN:9;
        per cases;
        suppose
          j is even;
          then consider m be Nat such that
A12:      j = 2*m by ABIAN:def 2;
          (diff(cos,Z).(i+1)).x = (diff(cos,Z).(2*j+1) `| Z).x by A11,
TAYLOR_1:def 5
            .=((-1) |^ (2*m+1) (#) sin | Z`| Z).x by A12,TAYLOR_2:19
            .=(((-1) |^ (2*m)*(-1)) (#) sin | Z`| Z).x by NEWTON:6
            .=((1|^ (2*m)*(-1)) (#) sin | Z`| Z).x by WSIERP_1:2
            .=((1*(-1)) (#) sin | Z`| Z).x
            .=((-sin)| Z`| Z).x by RFUNCT_1:49
            .=(((-1) (#) sin)`| Z).x by A7,FDIFF_2:16
            .=(-1)*diff(sin,x) by A1,A2,A6,FDIFF_1:20
            .=(-1)*(cos.x) by SIN_COS:64
            .=-cos.x
            .=cos.(x+PI) by SIN_COS:78
            .=cos.(x+PI+2*PI*m) by SIN_COS2:11
            .=cos.(x + (i+1)*PI/2) by A11,A12
            .=cos.(x+n*PI/2);
          hence thesis;
        end;
        suppose
          j is odd;
          then consider s be Nat such that
A13:      j = 2*s+1 by ABIAN:9;
          (diff(cos,Z).(i+1)).x = (diff(cos,Z).(2*j+1) `| Z).x by A11,
TAYLOR_1:def 5
            .=((-1) |^ (j+1) (#) sin | Z`| Z).x by TAYLOR_2:19
            .=(1|^ (2*(s+1)) (#) sin |Z`| Z).x by A13,WSIERP_1:2
            .=(1 (#) sin | Z`| Z).x
            .=( sin | Z`| Z).x by RFUNCT_1:21
            .=(sin`|Z).x by A6,FDIFF_2:16
            .=diff(sin,x) by A1,A6,FDIFF_1:def 7
            .=cos.x by SIN_COS:64
            .=cos.(x+(2*PI*s)) by SIN_COS2:11
            .=cos.(x+(((i-1)/2-1)*PI)+2*PI) by A11,A13,SIN_COS:78
            .=cos.(x+n*PI/2);
          hence thesis;
        end;
      end;
    end;
    hence thesis;
  end;
  suppose
A14: n=0;
    then (diff(cos,Z).n).x =(cos|Z).x by TAYLOR_1:def 5
      .=cos.(x+n*PI/2) by A1,A14,FUNCT_1:49;
    hence thesis;
  end;
end;
