reserve D for set;
reserve x,x0,x1,x2,y,y0,y1,y2,z,z0,z1,z2,r,s,t for Real;
reserve p,a,u,u0 for Element of REAL 3;
reserve n,m,k for Element of NAT;
reserve f,f1,f2,f3,g for PartFunc of REAL 3,REAL;
reserve R,R1,R2 for RestFunc;
reserve L,L1,L2 for LinearFunc;

theorem
  f is total & f is constant implies grad(f,p) = 0.REAL 3
proof
     assume
A1:  f is total & f is constant;
then A2:  dom f = REAL 3 by FUNCT_2:def 1;
     REAL = [#]REAL;
     then reconsider W = REAL as open Subset of REAL;
     consider a being Element of REAL such that
A3:  for p st p in REAL 3 holds f.p = a by A1,A2,PARTFUN2:def 1;
     now
       let x be Element of REAL;
       assume x in dom (f*reproj(1,p));then
    (f*reproj(1,p)).x = f.(reproj(1,p).x) by FUNCT_1:12;
       hence (f*reproj(1,p)).x = a by A3;
     end; then
A4:  f*reproj(1,p) is constant by PARTFUN2:def 1;
     set g1 = f*reproj(1,p);
A5:  dom g1 = W by A1,FUNCT_2:def 1;
A6:  g1|W is constant by A4;
then A7: g1 is_differentiable_on REAL by A5,FDIFF_1:22;
 for x st x in REAL holds diff(g1,x) = 0
     proof
       let x;
       assume x in REAL;
       reconsider x as Element of REAL by XREAL_0:def 1;
       diff(g1,x) = (g1`|W).x by A7,FDIFF_1:def 7
       .= 0 by A5,A6,FDIFF_1:22;
       hence thesis;
     end;
then A8: partdiff(f,p,1) = 0;
     now
       let y be Element of REAL;
       assume y in dom (f*reproj(2,p));then
       (f*reproj(2,p)).y = f.(reproj(2,p).y) by FUNCT_1:12;
       hence (f*reproj(2,p)).y = a by A3;
     end;
     then
A9: f*reproj(2,p) is constant by PARTFUN2:def 1;
     set g2 = f*reproj(2,p);
A10: dom g2 = W by A1,FUNCT_2:def 1;
A11: g2|W is constant by A9;
then A12: g2 is_differentiable_on REAL & for y being Real st y in REAL
     holds (g2`|W).y = 0 by A10,FDIFF_1:22;
 for y st y in REAL holds diff(g2,y) = 0
     proof
       let y;
       assume y in REAL;
       reconsider y as Element of REAL by XREAL_0:def 1;
       diff(g2,y) = (g2`|W).y by A12,FDIFF_1:def 7
       .= 0 by A10,A11,FDIFF_1:22;
       hence thesis;
     end;
then A13: partdiff(f,p,2) = 0;
     now
       let z be Element of REAL;
       assume z in dom (f*reproj(3,p));then
   (f*reproj(3,p)).z = f.(reproj(3,p).z) by FUNCT_1:12;
       hence (f*reproj(3,p)).z = a by A3;
     end;
     then
A14: f*reproj(3,p) is constant by PARTFUN2:def 1;
     set g3 = f*reproj(3,p);
A15: dom g3 = W by A1,FUNCT_2:def 1;
A16: g3|W is constant by A14;
then A17: g3 is_differentiable_on REAL & for z being Real st z in REAL
     holds (g3`|W).z = 0 by A15,FDIFF_1:22;
 for z st z in REAL holds diff(g3,z) = 0
     proof
       let z;
       assume z in REAL;
       reconsider z as Element of REAL by XREAL_0:def 1;
       diff(g3,z) = (g3`|W).z by A17,FDIFF_1:def 7
       .= 0 by A15,A16,FDIFF_1:22;
       hence thesis;
     end;
then  partdiff(f,p,3) = 0;
     then grad(f,p) = |[ 0,0,0 ]| by A8,A13,Th34
      .= 0.REAL 3 by FINSEQ_2:62;
     hence thesis;
end;
