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 Th28:
for m,n be non zero Nat, f be PartFunc of REAL m,REAL n,
   x,y be Element of REAL m holds
 ex h be FinSequence of REAL m, g be FinSequence of REAL n st
  len h = m+1 & len g = m &
  (for i be Nat st i in dom h holds h/.i = (y| (m+1-'i))^(0*(i-'1))) &
  (for i be Nat st i in dom g holds g/.i = f/.(x+h/.i) - f/.(x+h/.(i+1))) &
  (for i be Nat, hi be Element of REAL m st
    i in dom h & h/.i= hi holds |. hi .| <=|. y .|) &
  f /.(x+y) - f/.x = Sum g
proof
   let m,n be non zero Nat,
       f be PartFunc of REAL m,REAL n,
       x,y be Element of REAL m;
    reconsider mm=m as Element of NAT by ORDINAL1:def 12;
A1:len y = mm by FINSEQ_2:133;
   defpred H[Nat,set] means $2=(y| (m+1-'$1))^(0*($1-'1));
A2:for k be Nat st k in Seg(m+1) ex x being Element of REAL m st H[k,x]
   proof
    let k be Nat;
    assume k in Seg(m+1);
then A3: 1 <= k & k <= m+1 by FINSEQ_1:1;
    then k-1 >= 0 & m+1 - k >= 0 by XREAL_1:48;
then A4: m+1-'k = m+1-k & k-'1 = k-1 by XREAL_0:def 2;
    set l1 = m+1-'k;
    set l2 = k-'1;
     m+1 <= m+k by A3,XREAL_1:6;
    then l1 <= len y by A1,A4,XREAL_1:20;
then A5: len(y|l1) = l1 by FINSEQ_1:59;
     len(0*l2) = l2 by FINSEQ_2:132;
    then len((y|l1)^(0*l2)) = l1 + l2 by A5,FINSEQ_1:22;
    then (y|l1)^(0*l2) is Element of (l1+l2)-tuples_on REAL by FINSEQ_2:133;
    hence thesis by A4;
   end;
   consider h be FinSequence of REAL m such that
A6:dom h = Seg(m+1) &
    for j being Nat st j in Seg(m+1) holds H[j,h.j] from FINSEQ_1:sch 5(A2);
A7:now let j be Nat;
    assume A8: j in dom h;
    then h/.j = h.j by PARTFUN1:def 6;
    hence h/.j = (y| (m+1-'j))^(0*(j-'1)) by A8,A6;
   end;
   deffunc Z(Nat)=f/.(x+h/.$1);
   consider z be FinSequence of REAL n such that
A9:len z = m+1 &
    for j being Nat st j in dom z holds z.j = Z(j) from FINSEQ_2:sch 1;
A10:now let j be Nat;
    assume A11:j in dom z;
    then z/.j = z.j by PARTFUN1:def 6;
    hence z/.j = f/.(x+h/.j) by A11,A9;
   end;
   deffunc G(Nat) = z/.$1 - z/.($1+1);
   consider g be FinSequence of REAL n such that
A12:len g = m &
    for j being Nat st j in dom g holds g.j = G(j) from FINSEQ_2:sch 1;
A13:now let j be Nat;
    assume A14: j in dom g;
    then g/.j = g.j by PARTFUN1:def 6;
    hence g/.j = z/.j - z /.(j+1) by A14,A12;
   end;
A15:1 <= m+1 by NAT_1:11;
A16:m+1-'1 = m+1-1 by NAT_1:11,XREAL_1:233;
    1 in dom h by A6,A15;
   then h/.1 = (y| (m+1-'1))^(0*(1-'1)) by A7;
   then h/.1 = (y|m)^(0*0) by A16,XREAL_1:232;
   then h/.1 = y^(0*0) by A1,FINSEQ_1:58;
then A17:h/.1 = y by FINSEQ_1:34;
A18:1 <= len z & len z <= m+1 by A9,NAT_1:14;
A19:m+1-'(len z) = m+1 - len z by A9,XREAL_1:233;
A20:len z -'1 = len z - 1 by A9,NAT_1:14,XREAL_1:233;
    len z in dom h by A6,A18;
   then h/.(len z) = (y|0)^(0*(len z -'1)) by A7,A19,A9;
then A21:h/.(len z) = 0*m by A20,A9,FINSEQ_1:34;
    1 <= m+1 by NAT_1:11;
   then 1 in Seg (m+1);
   then 1 in dom z by A9,FINSEQ_1:def 3;
then A22:z/.1 = f/. (x+y) by A10,A17;
    len z in Seg (m+1) by A9,FINSEQ_1:4;
   then len z in dom z by A9,FINSEQ_1:def 3;
   then z/.(len z) = f/. (x+h/.(len z)) by A10;
then A23:z/.(len z) = f/.x by A21,EUCLID_4:1;
   take h,g;
    m+1 in NAT by ORDINAL1:def 12;
   hence len h = m+1 & len g =m by A6,A12,FINSEQ_1:def 3;
A24:now let i be Nat;
    assume A25: i in dom g;
then A26:i in Seg m by A12,FINSEQ_1:def 3;
     m <= m+1 by NAT_1:11;
then A27: Seg m c= Seg (m+1) by FINSEQ_1:5;
     dom h= dom z by A6,A9,FINSEQ_1:def 3;
then A28: z/.i =f/. (x+h/.i) by A10,A27,A6,A26;
     i in Seg m by A12,A25,FINSEQ_1:def 3;
    then 1 <= i & i <= m by FINSEQ_1:1;
then A29:i +1 <= m+1 by XREAL_1:6;
     1 <= i+1 by NAT_1:11;
    then i+1 in Seg (m+1) by A29;
    then i+1 in dom z by A9,FINSEQ_1:def 3;
    then z/.(i+1)  =f /. (x+h/.(i+1)) by A10;
    hence g/.i = f /. (x+h/.i) - f /.(x+h/.(i+1)) by A13,A25,A28;
   end;
    for i be Nat, hi be Element of REAL m st
    i in dom h & h/.i= hi holds |. hi .| <=|. y .|
   proof
    let i be Nat, hi be Element of REAL m;
    assume i in dom h & h/.i = hi;
then A30:hi = (y| (m+1-'i))^(0*(i-'1)) by A7;
A31:for j be Nat st j in Seg m holds (sqr hi).j <= (sqr y).j
    proof
     let j be Nat;
     assume A32:j in Seg m;
      len hi = m by CARD_1:def 7;
then A33:  j in dom ((y| (m+1-'i))^(0*(i-'1))) by A32,A30,FINSEQ_1:def 3;
     per cases by A33,FINSEQ_1:25;
     suppose A34:j in dom (y| (m+1-'i));
     then j in Seg (len (y| (m+1-'i))) by FINSEQ_1:def 3;
then A35:  j <= len (y| (m+1-'i)) by FINSEQ_1:1;
     A36: len (y| (m+1-'i)) <= m+1-'i by FINSEQ_5:17;
       (sqr hi).j=(sqrreal*hi).j by RVSUM_1:def 8
               .=sqrreal.(((y| (m+1-'i))^(0*(i-'1))).j)
                by A30,A33,FUNCT_1:13
               .=sqrreal.((y| (m+1-'i)).j) by A34,FINSEQ_1:def 7
               .=sqrreal.(y.j) by A36,A35,FINSEQ_3:112,XXREAL_0:2
               .=(y.j)^2 by RVSUM_1:def 2
               .=(sqr y).j by VALUED_1:11;
      hence thesis;
     end;
     suppose ex k be Nat st k in dom (0*(i-'1)) & j=len (y| (m+1-'i)) + k;
     then consider k be Nat such that
A37:  k in dom (0*(i-'1)) & j=len (y| (m+1-'i)) + k;
A38:    (sqr hi).j=(sqrreal*hi).j by RVSUM_1:def 8
                .=sqrreal.(((y| (m+1-'i))^(0*(i-'1))).j)
                by A30,A33,FUNCT_1:13
                .= sqrreal.((0*(i-'1)).k) by A37,FINSEQ_1:def 7
                .=((0*(i-'1)).k)^2 by RVSUM_1:def 2
                .=0;
      (sqr y).j=(y.j)^2 by VALUED_1:11
             .=(y.j)*(y.j);
     hence thesis by A38,XREAL_1:63;
     end;
    end;
     0 <= Sum sqr hi by RVSUM_1:86;
    hence |. hi .| <= |. y .| by A31,RVSUM_1:82,SQUARE_1:26;
   end;
   hence thesis by A7,A22,A23,A24,A9,A12,A13,Th26;
end;
