reserve i,j,k,n,m for Nat,
        X for set,
        b,s for bag of X,
        x for object;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
          right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
             right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;

theorem Th83:
  for L being right_zeroed add-associative right_complementable
       well-unital distributive non trivial doubleLoopStr,
     p being Polynomial of n+m,L st vars p c= n
     ex q being Polynomial of n,L st
        vars q c= n
         & rng q c= rng p &
        (for b be bag of n+m holds b|n in Support q &
         (for i st i >= n holds b.i=0) iff b in Support p)&
        (for b be bag of n+m st b in Support p holds
           q.(b|n) = p.b) &
     for x being Function of (n+m), L,
         y being Function of n, L st x|n=y
       holds eval(p,x) = eval(q,y)
proof
  let L be right_zeroed add-associative right_complementable
  well-unital distributive non trivial doubleLoopStr,
  p be Polynomial of n+m,L;
  assume
A1: vars p c= n;
  defpred P[Nat] means $1 <=m &
  ex q being Polynomial of n+$1,L st
  vars q c= n & rng q c= rng p &
  (for b be bag of n+m holds b|(n+$1) in Support q &
  (for i st i >= n+$1 holds b.i=0)
  iff b in Support p)&
  (for b be bag of n+m st b in Support p holds q.(b|(n+$1)) = p.b) &
  for x being Function of (n+m), L,y being Function of n+$1, L st x|(n+$1)=y
  holds eval(p,x) = eval(q,y);
A2: ex k st P[k]
  proof
    take m;
    thus m <= m;
    take q=p;
    thus vars q c= n & rng q c= rng p by A1;
    thus for b be bag of n+m holds b|(n+m) in Support q
    & (for i st i >= n+m holds b.i=0 ) iff b in Support p
    proof
      let b be bag of n+m;
      for i st i >= n+m holds b.i=0
      proof
        let i;
        assume i >=n+m;
        then not i in Segm (n+m) by NAT_1:44;
        then not i in dom b;
        hence thesis by FUNCT_1:def 2;
      end;
      hence thesis;
    end;
    thus thesis;
  end;
A3:for k being Nat st k <> 0 & P[k] ex n being Nat st n < k & P[n]
  proof
    let k1 be Nat such that
A4: k1 <> 0 & P[k1];
    consider q be Polynomial of n+k1,L such that
A5: vars q c= n and
A6: rng q c= rng p and
A7:   for b be bag of n+m holds b|(n+k1) in Support q
    & (for i st i >= n+k1 holds b.i=0 ) iff b in Support p and
A8: for b be bag of n+m st b in Support p holds q.(b|(n+k1)) = p.b and
A9: for x being Function of (n+m), L,
      y being Function of n+k1, L st x|(n+k1)=y
      holds eval(p,x) = eval(q,y) by A4;
    reconsider k=k1-1 as Nat by A4;
    reconsider q1=q as Polynomial of n+k+1,L;
    take k;
    k1=k+1;
    hence k < k1 by NAT_1:13;
A10: n+(k+1) <= n+m by A4,XREAL_1:7;
A11: Segm(n+k+1) c= Segm(n+m) by A4,XREAL_1:7,NAT_1:39;
A12:k+1 <= m by A4;
    thus k <=m by A12,NAT_1:13;
    take Q=q1 removed_last;
A13: vars Q c= (vars q1)\{n+k} by Th52;
    vars q1\{n+k} c= n\{n+k} c= n by A5,XBOOLE_1:35;
    hence vars Q c= n by A13;
A14:dom Q = Bags (n+k) & dom q1 = Bags (n+k+1) by PARTFUN1:def 2;
    thus rng Q c= rng p
    proof
      let y be object;
      assume y in rng Q;
      then consider x such that
A15:  x in dom Q & Q.x = y by FUNCT_1:def 3;
      reconsider x as Element of Bags(n+k) by A15;
A16:  Q.x = q1.(x bag_extend 0) by Def6;
      q1.(x bag_extend 0) in rng q1 by A14,FUNCT_1:def 3;
      hence thesis by A16,A6,A15;
    end;
A17:n+k < n+k+1 by NAT_1:13;
    then
A18:Segm(n+k) c= Segm(n+k+1) & n+k in Segm(n+k+1) by NAT_1:39,44;
    thus for b be bag of n+m holds b| (n+k) in Support Q &
    (for i st i >= n+k holds b.i=0) iff b in Support p
    proof
      let b be bag of n+m;
      thus b|(n+k) in Support Q & (for i st i >= n+k holds b.i=0)
      implies b in Support p
      proof
        assume
A19:    b|(n+k) in Support Q & (for i st i >= n+k holds b.i=0);
        then reconsider b1=b|(n+k) as Element of Bags(n+k);
        q1.(b1 bag_extend 0) = Q.b1<>0.L by Def6,A19,POLYNOM1:def 3;
        then
A20:    b1 bag_extend 0 in Support q1 by A14,POLYNOM1:def 3;
        b|(n+k+1) is bag of n+k+1
        proof
          per cases by A10,XXREAL_0:1;
          suppose n+k+1=n+m;
            hence thesis;
          end;
          suppose n+k+1<n+m;
            then n+k+1 in Segm(n+m) by NAT_1:44;
            hence thesis by BAGORDER:20;
          end;
        end;
        then reconsider bn=b|(n+k+1) as Element of Bags(n+k+1)
        by PRE_POLY:def 12;
        b.(n+k) = 0 by A19;
        then bn|(n+k) = b1 & bn.(n+k) = 0 by FUNCT_1:49,RELAT_1:74,A18;
        then
A21:    bn in Support q1 by A20,HILBASIS:def 1;
        for i st i >= n+k+1 holds b.i=0
        proof
          let i;
          assume i >= n+k+1;
          then i > n+k by NAT_1:13;
          hence thesis by A19;
        end;
        hence b in Support p by A7,A21;
      end;
      assume
A22:  b in Support p;
      then
A23:  b|(n+k1) in Support q & (for i st i >= n+k1 holds b.i=0 ) by A7;
      then reconsider bn = b|(n+k1) as Element of Bags(n+k+1);
A24:  q.bn<>0.L by A23,POLYNOM1:def 4;
A25:  bn.(n+k) = b.(n+k) by A18,FUNCT_1:49;
      not n+k in Segm n by NAT_1:11,44;
      then
A26:  not n+k in vars p by A1;
      then b.(n+k)=0 by A22,Def5;
      then
A27:  bn = (0,n+k)-cut bn bag_extend 0 by A25,HILB10_2:4;
A28:  n+k-'0 = n+k-0;
      then reconsider c = (0,n+k)-cut bn as Element of Bags(n+k)
      by PRE_POLY:def 12;
      c = bn|(n+k) by HILB10_2:3,A17;
      then
A29:  c = b|(n+k) by RELAT_1:74,A18;
A30:  Q.c = q1.(c bag_extend 0) by Def6;
      for i st i >= n+k holds b.i=0
      proof
        let i;assume i >=n+k;
        then i=n+k or i > n+k by XXREAL_0:1;
        then i=n+k or i >= n+k+1 by NAT_1:13;
        hence thesis by A26,A22,Def5,A7;
      end;
      hence thesis by A30,A27,A28,A24,POLYNOM1:def 4,A29;
    end;
A31: not n+k in Segm n by NAT_1:11,44;
    then
A32:not n+k in vars p by A1;
    thus for b be bag of n+m st b in Support p holds
    Q.(b|(n+k)) = p.b
    proof
      let b be bag of n+m such that
A33:  b in Support p;
      b|(n+k1) in Support q & (for i st i >= n+k1 holds b.i=0 ) by A7,A33;
      then reconsider bn = b|(n+k1) as Element of Bags(n+k+1);
A34:  bn.(n+k) = b.(n+k) by A18,FUNCT_1:49;
      b.(n+k)=0 by A33,Def5,A32;
      then
A35:  bn = (0,n+k)-cut bn bag_extend 0 by A34,HILB10_2:4;
A36:  n+k-'0 = n+k-0;
      then reconsider c = (0,n+k)-cut bn as Element of Bags(n+k)
      by PRE_POLY:def 12;
      c = bn|(n+k) by HILB10_2:3,A17;
      then
A37:  c = b|(n+k) by RELAT_1:74,A18;
      Q.c = q1.bn by Def6,A35,A36;
      hence thesis by A37,A33,A8;
    end;
    let x be Function of (n+m), L,
    y be Function of n+k,L such that
A38: x|(n+k)=y;
A39:rng (x| (n+k+1)) c= the carrier of L by RELAT_1:def 19;
    n+k+1 c= dom x by A11,FUNCT_2:def 1;
    then dom (x|(n+k+1)) = n+k+1 =n+k1 by RELAT_1:62;
    then reconsider z = x| (n+k+1) as Function of n+k1,L by A39,FUNCT_2:2;
A40:eval(p,x) = eval(q,z) by A9;
    z | (n+k) = y by A38,RELAT_1:74,A18;
    hence thesis by A40,A31,A5,Th51;
  end;
  P[0] from NAT_1:sch 7(A2,A3);
  hence thesis;
end;
