reserve n for Nat,
        p,p1,p2 for Point of TOP-REAL n,
        x for Real;
reserve n,m for non zero Nat;
reserve i,j for Nat;
reserve f for PartFunc of REAL-NS m,REAL-NS n;
reserve g for PartFunc of REAL m,REAL n;
reserve h for PartFunc of REAL m,REAL;
reserve x for Point of REAL-NS m;
reserve y for Element of REAL m;
reserve X for set;

theorem Th42:
for m be non zero Nat, f be PartFunc of REAL m,REAL,
    p,q be Real,
    x be Element of REAL m,
    i be Nat
 st 1 <= i & i <= m
    & p < q
    & (for h be Real st h in [. p,q .] holds reproj(i,x).h in dom f)
    & (for h be Element of REAL st h in [. p,q .] holds
         f is_partial_differentiable_in reproj(i,x).h,i)
 ex r be Real, y be Element of REAL m st
  r in ]. p,q .[ & y = reproj(i,x).r
  & f/.(reproj(i,x).q) - f/.(reproj(i,x).p) = (q-p) * partdiff(f,y,i)
proof
   let m be non zero Nat,
       f be PartFunc of REAL m,REAL,
       p,q be Real,
       x be Element of REAL m,
       i be Nat;
   assume A1:
    1 <=i & i <= m & p < q
    & (for h be Real st h in [. p,q .] holds reproj(i,x).h in dom f)
    & (for h be Element of REAL st h in [. p,q .] holds
         f is_partial_differentiable_in (reproj(i,x).h),i);
   set g=f*reproj(i,x);
    now let h be object;
    assume A2: h in [. p,q .];
    then reconsider h1=h as Element of REAL;
A3: dom (reproj(i,x)) = REAL by PDIFF_1:def 5;
     reproj(i,x).h1 in dom f by A1,A2;
    hence h in dom g by A3,FUNCT_1:11;
   end;
then A4:[. p,q .] c= dom g;
A5:now let x0 be Real;
    assume A6: x0 in [. p,q .];
    reconsider xx=x0 as Element of REAL by XREAL_0:def 1;
    set y=reproj(i,x).xx;
A7: proj(i,m).y=x0 by Th39,A1;
     f is_partial_differentiable_in y,i by A1,A6;
    then f*reproj(i,y) is_differentiable_in x0 by A7;
    hence g is_differentiable_in x0 by Th40,A1;
   end;
    now let z be object;
    assume z in ].p,q.[;
    then ex z1 be Real st z=z1 & p < z1 & z1 < q;
    hence z in [. p,q .];
   end;
then A8:
   ].p,q.[ c= [. p,q .];
then A9:
   ].p,q.[ c= dom g by A4;
    for x be Real st x in ].p,q.[
    holds g is_differentiable_in x by A5,A8;
then A10:g is_differentiable_on ].p,q.[ by A9,FDIFF_1:9;
    now let x0,r be Real;
    assume A11: x0 in [. p,q .] & 0 < r;
    then g is_continuous_in x0 by A5,FDIFF_1:24;
    then consider s be Real such that
A12:  0<s & for x1 be Real st
             x1 in dom g & |.x1-x0.|<s holds |.g.x1-g.x0.| < r
      by A11,FCONT_1:3;
    take s;
    thus 0<s by A12;
    thus for x1 be Real st
     x1 in [. p,q .] & |.x1-x0.|<s holds |.g.x1-g.x0.|<r by A4,A12;
   end;
   then g| [.p,q.] is continuous by A4,FCONT_1:14;
   then consider r be Real such that
A13: r in ].p,q.[ & diff(g,r) = (g.q-g.p)/(q-p) by A1,A4,A10,ROLLE:3;
    q-p <> 0 by A1;
then A14:diff(g,r)*(q-p) = g.q-g.p by A13,XCMPLX_1:87;
A15:p in {s where s is Real: p<=s & s<=q} by A1;
then A16:f/.(reproj(i,x).p) = f.(reproj(i,x).p) by A1,PARTFUN1:def 6
                     .= g.p by A4,A15,FUNCT_1:12;
A17:q in {s where s is Real: p<=s & s<=q} by A1;
then A18:f/.(reproj(i,x).q) = f.(reproj(i,x).q) by A1,PARTFUN1:def 6
      .= g.q by A4,A17,FUNCT_1:12;
   reconsider r as Element of REAL by XREAL_0:def 1;
   set y =reproj(i,x).r;
   diff(g,r) = partdiff(f,y,i) by A1,Th41;
   hence thesis by A13,A14,A16,A18;
end;
