reserve n for non zero Element of NAT;
reserve a,b,r,t for Real;
reserve
  Z for open Subset of REAL,
 y0 for VECTOR of REAL-NS n,
  G for Function of REAL-NS n,REAL-NS n;

theorem Th39:
for g be PartFunc of REAL,REAL-NS n,
   x0 be Real,
    i be Nat st
 1 <= i & i <= n & g is_differentiable_in x0 holds
   (proj(i,n)*g) is_differentiable_in x0 &
   proj(i,n).(diff(g,x0)) = diff((proj(i,n)*g),x0)
proof
  let g be PartFunc of REAL,REAL-NS n,
     x0 be Real,
      i be Nat;
  assume A1: 1 <= i & i <= n & g is_differentiable_in x0; then
  consider N being Neighbourhood of x0 such that
A2: N c= dom g & ex DFG be LinearFunc of REAL-NS n,
        GR be RestFunc of REAL-NS n st diff(g,x0) = DFG/.1 &
    for x be Real st x in N holds
      g/.x - g/.x0 = DFG/.(x-x0) + GR/.(x-x0) by NDIFF_3:def 4;
  consider DFG be LinearFunc of REAL-NS n,
            GR be RestFunc of REAL-NS n such that
A3: diff(g,x0) = DFG/.1 &
    for x be Real st x in N holds
     g/.x - g/.x0 = DFG/.(x-x0) + GR/.(x-x0) by A2;
  consider LP be Point of REAL-NS n such that
A4: for p be Real holds DFG/.p = p*LP by NDIFF_3:def 2;
A5: the carrier of REAL-NS n = REAL n by REAL_NS1:def 4; then
  reconsider PG = proj(i,n) as Function of REAL-NS n,REAL;
  the carrier of REAL-NS n = REAL n by REAL_NS1:def 4; then
  reconsider L = proj(i,n)*DFG as Function of REAL,REAL;
A6: for r being Real holds L.r = (proj(i,n).LP)*r
  proof
    let r be Real;
A7: dom L = REAL by FUNCT_2:def 1;
    dom DFG = REAL by FUNCT_2:def 1; then
    DFG.r = DFG/.r by XREAL_0:def 1,PARTFUN1:def 6 .= r*LP by A4; then
    proj(i,n).(DFG.r) = r*(proj(i,n).LP) by Th38;
    hence L.r = (proj(i,n).LP)*r by A7,FUNCT_1:12,XREAL_0:def 1;
  end;
  reconsider L as LinearFunc by A6,FDIFF_1:def 3;
A8: GR is total by NDIFF_3:def 1; then
  reconsider FGR = GR as Function of REAL,REAL-NS n;
A9: proj(i,n)*FGR is Function of REAL,REAL by A5;
  proj(i,n)*GR is RestFunc
  proof
  A10: dom GR = REAL by A8,PARTFUN1:def 2;
    reconsider R = proj(i,n)*GR as PartFunc of REAL,REAL;
    for r be Real st r > 0 ex d be Real st d > 0 &
      (for z be Real st z <> 0 & |.z.| < d
         holds (|.z.|" * |. R/.z .|) < r)
    proof
      let r be Real;
      assume r > 0; then
      consider d be Real such that
    A11: d > 0 & (for z be Real st z <> 0 & |.z.| < d holds
        (|.z.|"* ||. GR/.z .||) < r) by A8,NDIFF_4:23;
      take d;
      thus d> 0 by A11;
      let z be Real;
      assume A12: z <> 0 & |.z.| < d;
A13:    z in REAL by XREAL_0:def 1;
    A14: GR/.z = GR.z by A10,PARTFUN1:def 6,XREAL_0:def 1;
    A15: i in Seg n by A1;
      reconsider GRz = GR/.z as Point of REAL-NS n;
      reconsider GRz1 = GRz as Element of REAL n by REAL_NS1:def 4;
      reconsider GRzi = GRz1.i as Real;
      the carrier of REAL-NS n = REAL n by REAL_NS1:def 4; then
      dom proj(i,n) = the carrier of REAL-NS n by PARTFUN1:def 2; then
    A16: z in dom (proj(i,n)*GR) by A10,A14,FUNCT_1:11,A13; then
    A17: (proj(i,n)*GR).z = proj(i,n).(GR.z) by FUNCT_1:12
                         .= proj(i,n).(GRz1) by A10,A13,PARTFUN1:def 6;
    A18: |.GRzi.| <= ||. GR/.z .|| by A15,REAL_NS1:9;
    A19: 0 <= |.z.| by COMPLEX1:46;
      0 <= |.GRzi.| by COMPLEX1:46; then
    A20: |.z.|"* |.GRzi.| <= |.z.|"* ||. GR/.z .|| by A18,A19,XREAL_1:66;
         |.z.|"* ||. GR/.z .|| < r by A11,A12; then
    A21: |.z.|"* |.GRzi.| < r by A20,XXREAL_0:2;
      reconsider Rz = (proj(i,n)*GR).z as Element of REAL by XREAL_0:def 1;
      |.z.|"* |. Rz .| < r by A21,PDIFF_1:def 1,A17;
      hence thesis by A16,PARTFUN1:def 6;
    end;
    hence thesis by A9,Th35;
  end; then
  reconsider R = proj(i,n)*GR as RestFunc;
  set pg = proj(i,n)*g;
  the carrier of REAL-NS n = REAL n by REAL_NS1:def 4; then
  dom proj(i,n) = the carrier of REAL-NS n by FUNCT_2:def 1; then
  rng g c= dom proj(i,n); then
A22: dom g = dom (proj(i,n)*g) by RELAT_1:27;
A23: for x be Real st x in N holds
      pg.x - pg.x0 = L.(x-x0) + R.(x-x0)
  proof
    let x be Real;
    reconsider xx = x as Element of REAL by XREAL_0:def 1;
    now assume A24: x in N; then
 A25: g/.x - g/.x0 = DFG/.(xx-x0) + GR/.(xx-x0) by A3;
 A26: x0 in N by RCOMP_1:16;
 A27: g/.x = g.x & g/.x0 = g.x0 by A2,A24,A26,PARTFUN1:def 6;
      reconsider PGSx = pg.x - pg.x0 as Element of REAL by XREAL_0:def 1;
      reconsider PGdx = pg.x as Element of REAL by XREAL_0:def 1;
      reconsider PGdx0 = pg.x0 as Element of REAL by XREAL_0:def 1;
      g.x in rng g by A2,A24,FUNCT_1:3; then
      reconsider Gx = g.x as Element of REAL n by REAL_NS1:def 4;
      g.x0 in rng g by A2,A26,FUNCT_1:3; then
      reconsider Gx0 = g.x0 as Element of REAL n by REAL_NS1:def 4;
      set projGx = proj(i,n).(g.x);
      reconsider projGx as Element of REAL by XREAL_0:def 1;
      set projGx0 = proj(i,n).(g.x0);
      reconsider projGx0 as Element of REAL by XREAL_0:def 1;
      reconsider Gx1 = Gx as Element of REAL-NS n by REAL_NS1:def 4;
      reconsider Gx01 = Gx0 as Element of REAL-NS n by REAL_NS1:def 4;
      reconsider Gsx = g/.x as Element of REAL n by REAL_NS1:def 4;
      reconsider Gsx0 = g/.x0 as Element of REAL n by REAL_NS1:def 4;
      reconsider dxx0 = x-x0 as Element of REAL by XREAL_0:def 1;
      reconsider Ldxx0 = L.(x-x0) as Element of REAL by XREAL_0:def 1;
 A28: dom R = REAL by A9,PARTFUN1:def 2;
      reconsider Rdxx0 = R.(x-x0) as Element of REAL by XREAL_0:def 1;
      reconsider Lxx0Rxx0 = L.(x-x0) + R.(x-x0) as Element of REAL
        by XREAL_0:def 1;
      reconsider Ldiff = DFG/.(x-x0) as Element of REAL n by REAL_NS1:def 4;
      set projLdiff = proj(i,n).Ldiff;
      reconsider projLdiff as Element of REAL;
 A29: dom GR = REAL by A8,PARTFUN1:def 2; then
      GR.dxx0 in rng GR by FUNCT_1:3; then
      reconsider Rdiff = GR.dxx0 as Element of REAL n by REAL_NS1:def 4;
      set projRdiff = proj(i,n).Rdiff;
      reconsider projRdiff as Element of REAL;
      dom DFG = REAL by FUNCT_2:def 1; then
A30:    Ldiff = DFG.(x-x0) by PARTFUN1:def 6,XREAL_0:def 1;
      dom L = REAL by FUNCT_2:def 1; then
 A31: L.(x-x0) = proj(i,n).Ldiff by FUNCT_1:12,XREAL_0:def 1,A30;
 A32: R.(x-x0) = proj(i,n).Rdiff by A28,FUNCT_1:12;
 A33: proj(i,n).Ldiff = Ldiff.i by PDIFF_1:def 1;
 A34: proj(i,n).Rdiff = Rdiff.i by PDIFF_1:def 1;
      reconsider diffGR = DFG/.(x-x0) + GR/.(x-x0)
        as Element of REAL n by REAL_NS1:def 4;
      reconsider Rsdiff = GR/.(x-x0) as Element of REAL n by REAL_NS1:def 4;
      PGSx = projGx - PGdx0 by A2,A22,A24,FUNCT_1:12
          .= proj(i,n).Gx1 - proj(i,n).Gx01 by A2,A22,A26,FUNCT_1:12
          .= Gx.i - proj(i,n).Gx01 by PDIFF_1:def 1
          .= Gx.i - Gx0.i by PDIFF_1:def 1
          .= (Gsx - Gsx0).i by A27,RVSUM_1:27
          .= diffGR.i by A25,REAL_NS1:5
          .= (Ldiff + Rsdiff).i by REAL_NS1:2
          .= Ldiff.i + Rsdiff.i by RVSUM_1:11;
      hence thesis by A31,A33,A34,A29,PARTFUN1:def 6,A32;
    end;
    hence thesis;
  end;
  hence A35: proj(i,n)*g is_differentiable_in x0 by A2,A22;
  L.1 = 1*(proj(i,n).LP) by A6
     .= proj(i,n).((1 qua Real) * LP) by RLVECT_1:def 8
     .= proj(i,n).diff(g,x0) by A3,A4;
  hence proj(i,n).diff(g,x0) = diff((proj(i,n)*g),x0)
     by A35,A2,A22,A23,FDIFF_1:def 5;
end;
