reserve Z for open Subset of REAL;

theorem Th21:
  for n be Element of NAT holds sin is_differentiable_on n, Z &
  cos is_differentiable_on n, Z
proof
  let n be Element of NAT;
  now
    let i be Nat such that
    i <= n-1;
A1: now
      per cases;
      suppose
        i is even;
        then consider j be Nat such that
A2:     i=2*j by ABIAN:def 2;
        thus dom(diff(sin,Z).i) = dom((-1) |^ j (#) sin | Z) by A2,Th19
          .= dom((sin | Z)) by VALUED_1:def 5
          .= Z by Th17;
      end;
      suppose
        i is odd;
        then consider j be Nat such that
A3:     i=2*j+1 by ABIAN:9;
        thus dom(diff(sin,Z).i) = dom((-1) |^ j (#) cos | Z) by A3,Th19
          .= dom((cos | Z)) by VALUED_1:def 5
          .= Z by Th17;
      end;
    end;
    for x be Real st x in Z
       holds diff(sin,Z).i | Z is_differentiable_in x
    proof
      let x be Real such that
A4:   x in Z;
      now
        per cases;
        suppose
          i is even;
          then consider j be Nat such that
A5:       i = 2*j by ABIAN:def 2;
          sin is_differentiable_on Z by FDIFF_1:26,SIN_COS:68;
          then
A6:       (sin | Z) is_differentiable_in x by A4,FDIFF_1:def 6;
          diff(sin,Z).i = (-1) |^ j (#) sin | Z by A5,Th19;
          hence diff(sin,Z).i is_differentiable_in x by A6,FDIFF_1:15;
        end;
        suppose
          i is odd;
          then consider j be Nat such that
A7:       i = 2*j+1 by ABIAN:9;
          cos is_differentiable_on Z by FDIFF_1:26,SIN_COS:67;
          then
A8:       (cos | Z) is_differentiable_in x by A4,FDIFF_1:def 6;
          diff(sin,Z).i = (-1) |^ j (#) cos | Z by A7,Th19;
          hence diff(sin,Z).i is_differentiable_in x by A8,FDIFF_1:15;
        end;
      end;
      hence thesis by A1,RELAT_1:68;
    end;
    hence diff(sin,Z).i is_differentiable_on Z by A1,FDIFF_1:def 6;
  end;
  hence sin is_differentiable_on n, Z;
  now
    let i be Nat such that
    i <= n-1;
A9: now
      per cases;
      suppose
        i is even;
        then consider j be Nat such that
A10:    i = 2*j by ABIAN:def 2;
        thus dom(diff(cos,Z).i) = dom((-1) |^ j (#) cos | Z) by A10,Th19
          .= dom((cos | Z)) by VALUED_1:def 5
          .= Z by Th17;
      end;
      suppose
        i is odd;
        then consider j be Nat such that
A11:    i = 2*j+1 by ABIAN:9;
        thus dom(diff(cos,Z).i) = dom((-1) |^ (j+1) (#) sin | Z) by A11,Th19
          .= dom((sin | Z)) by VALUED_1:def 5
          .= Z by Th17;
      end;
    end;
    for x be Real
      st x in Z holds diff(cos,Z).i | Z is_differentiable_in x
    proof
      let x be Real such that
A12:  x in Z;
      now
        per cases;
        suppose
          i is even;
          then consider j be Nat such that
A13:      i = 2*j by ABIAN:def 2;
          cos is_differentiable_on Z by FDIFF_1:26,SIN_COS:67;
          then
A14:      (cos | Z) is_differentiable_in x by A12,FDIFF_1:def 6;
          diff(cos,Z).i = (-1) |^ j (#) cos | Z by A13,Th19;
          hence diff(cos,Z).i is_differentiable_in x by A14,FDIFF_1:15;
        end;
        suppose
          i is odd;
          then consider j be Nat such that
A15:      i = 2*j+1 by ABIAN:9;
          sin is_differentiable_on Z by FDIFF_1:26,SIN_COS:68;
          then
A16:      (sin | Z) is_differentiable_in x by A12,FDIFF_1:def 6;
          diff(cos,Z).i = (-1) |^ (j+1) (#) sin | Z by A15,Th19;
          hence diff(cos,Z).i is_differentiable_in x by A16,FDIFF_1:15;
        end;
      end;
      hence thesis by A9,RELAT_1:68;
    end;
    hence diff(cos,Z).i is_differentiable_on Z by A9,FDIFF_1:def 6;
  end;
  hence thesis;
end;
