reserve i,j,k,n,m for Nat,
        b,b1,b2 for bag of n;

theorem Th17:
  for L being right_zeroed add-associative right_complementable
    well-unital distributive non trivial doubleLoopStr
  for p being Polynomial of n,L
  holds
    len SgmX(BagOrder n, Support p) =
      len SgmX(BagOrder (n+1), Support (p extended_by_0)) &
    for i be Nat st 1<=i<= len SgmX(BagOrder n, Support p) holds
      SgmX(BagOrder (n+1), Support (p extended_by_0))/.i =
        SgmX(BagOrder n, Support p)/.i bag_extend 0
proof
  let L be right_zeroed add-associative right_complementable
  well-unital distributive non trivial doubleLoopStr;
  let p be Polynomial of n,L;
  set B=BagOrder n,B1=BagOrder (n+1);
  set P=p extended_by_0;
A1:n-'0=n by NAT_D:40;
A2:B linearly_orders Support p & B1 linearly_orders Support P by POLYNOM2:18;
  deffunc F(bag of n) = $1 bag_extend 0;
A3: for x being Element of Bags n holds F(x) in Bags(n+1);
  consider f be Function of Bags n,Bags (n+1) such that
A4: for x being Element of Bags n holds f.x = F(x) from FUNCT_2:sch 8(A3);
  set F=f|(Support p);
A5:dom F = Support p by FUNCT_2:def 1;
  set Sp=SgmX(B, Support p),SP=SgmX(B1, Support P);
A6: rng F c= Support P
  proof
    let y be object;
    assume y in rng F;
    then consider x be object such that
A7: x in dom F & F.x=y by FUNCT_1:def 3;
    reconsider x as Element of Bags n by A7,A5;
A8: f.x =F.x by A7,FUNCT_1:47;
    f.x = F(x) by A4;
    hence thesis by A7,A8,Th8;
  end;
  Support P c= rng F
  proof
    let y be object;
    assume
A9:y in Support P;
    then reconsider b=y as bag of n+1;
    set C=(0,n)-cut b;
A10: b.n=0 by A9,Th7;
    then
A11: C in Support p by A9,Th9;
    then reconsider C as Element of Bags n;
    F(C)=f.C = F.C by A11,A4,FUNCT_1:49;
    then
A12: F(C) in rng F by A11,A5,FUNCT_1:def 3;
    n-'0=n by NAT_D:40;
    hence thesis by A12,A10,Th4;
  end;
  then
A13: Support P = rng F by A6,XBOOLE_0:def 10;
  F is one-to-one
  proof
    let x1,x2 be object;
    assume
A14: x1 in dom F & x2 in dom F & F.x1=F.x2;
    reconsider x1,x2 as Element of Bags n by A14,A5;
A15: f.x1 =F.x1 & f.x2 = F.x2 by A14,FUNCT_1:47;
    f.x1 = F(x1) & f.x2 = F(x2) by A4;
    then F(x1)=F(x2) & x1=F(x1) |n by HILBASIS:def 1, A15,A14;
    hence thesis by HILBASIS:def 1;
  end;
  then
A16: len Sp = card Support p = card Support P = len SP
    by CARD_1:5,POLYNOM2:18,PRE_POLY:11,A5,A13,WELLORD2:def 4;
  hence len Sp= len SP;
  defpred P[Nat] means 1<=$1 <= len Sp implies
    for i st 1<= i <= $1 holds SP/.i = Sp/.i bag_extend 0;
A17: rng Sp =Support p & rng SP =Support P by A2,PRE_POLY:def 2;
A18:P[0];
A19:for k be Nat st P[k] holds P[k+1]
  proof
    let k be Nat;set k1=k+1;
    assume that
A20:P[k] and A21:1<= k1<=len Sp;
    let i be Nat such that
A22: 1<= i <=k1;
A23: k < len Sp by A21,NAT_1:13;
A24:  k = len (SP|k) by A23,A16,FINSEQ_1:59;
A25: rng (Sp|k1) c= Support p &
    rng (SP|k1) c= Support P by A17,RELAT_1:70;
A26:Sp|k1 = (Sp|k) ^ <*Sp.k1*> &
    SP|k1 = (SP|k) ^ <*SP.k1*> by A16,A21,NAT_1:13,FINSEQ_5:83;
A27:k1 in dom Sp & k1 in dom SP by A21,A16,FINSEQ_3:25;
    then
A28: Sp.k1 in rng Sp & SP.k1 in rng SP by FUNCT_1:def 3;
A29: Sp.k1 = Sp/.k1 & SP.k1 = SP/.k1 by A27,PARTFUN1:def 6;
    per cases by NAT_1:14;
    suppose
A30:  k=0;
A31:  i=1 by A30,A22,XXREAL_0:1;
A32:  Sp/.1 bag_extend 0 in Support P by Th8,A30,A29,A28,A17;
      for y be Element of Bags (n+1) st y in Support P
        holds [Sp/.1 bag_extend 0 ,y] in B1
      proof
        let y be Element of Bags (n+1);
        set Y=(0,n)-cut y;
        assume
A33:      y in Support P;
        then y.n =0 by Th7;
        then Y in Support p by A33,Th9;
        then consider w be object such that
A34:      w in dom Sp & Sp.w = Y by FUNCT_1:def 3,A17;
        y.n = 0 by Th7,A33;
        then
A35:      y = Y bag_extend 0 by Th4;
        reconsider w as Nat by A34;
A36:      Sp.w = Sp/.w by A34,PARTFUN1:def 6;
A37:      1<=w by A34,FINSEQ_3:25;
        per cases by A37,XXREAL_0:1;
        suppose w =1;
          hence thesis by PRE_POLY:def 14,A35,A1,A34,A36;
        end;
        suppose w>1; then
A38:        Sp/.1 <> Sp/.w & [Sp/.1,Sp/.w] in B
            by A2,PRE_POLY:def 2,A27,A34,A30;
          then Sp/.1 <=' Sp/.w by PRE_POLY:def 14;
          then Sp/.1 bag_extend 0 < Sp/.w bag_extend 0
            by Th14,A38,PRE_POLY:def 10;
          then Sp/.1 bag_extend 0 <=' y by A1,A34,A36,A35,PRE_POLY:def 10;
          hence thesis by PRE_POLY:def 14;
        end;
      end;
      hence SP/.i = Sp/.i bag_extend 0 by A31,A32,POLYNOM2:18,PRE_POLY:20;
    end;
    suppose
A39:    k >=1;
A40:    k1 in Seg k1 by A21;
      set Ck = (0,n)-cut SP/.k1;
      reconsider Ck as bag of n by A1;
A41:    SP/.k1 in rng (SP|k1) by PARTFUN2:18,A40,A27;
      then
A42:    (SP/.k1).n=0 by Th7,A25;
      then Ck in Support p by Th9,A41,A25;
      then consider f be object such that
A43:   f in dom Sp & Sp.f = Ck by FUNCT_1:def 3,A17;
      reconsider f as Nat by A43;
A44:  Sp/.f=Sp.f by A43,PARTFUN1:def 6;
A45:  SP/.k1 = Ck bag_extend 0 by A1,A42,Th4;
      set SpEk=Sp/.k1 bag_extend 0;
      SpEk in Support P by A29,A28,A17,Th8;
      then consider e be object such that
A46:  e in dom SP & SP.e = SpEk by FUNCT_1:def 3,A17;
      reconsider e as Nat by A46;
A47:  1<= e<= len SP by FINSEQ_3:25,A46;
A48:  SP/.e=SP.e by A46,PARTFUN1:def 6;
A49:  SP/.k = Sp/.k bag_extend 0 by A20,A39,A21,NAT_1:13;
A50:  SpEk in rng (SP|k1)
      proof
        assume
A51:      not SpEk in rng (SP|k1);
        e > k1
        proof
          assume e <=k1;
          then e in Seg k1 by A47;
          hence thesis by A51,A48,A46,PARTFUN2:18;
        end;
        then
A52:    Sp/.f < Sp/.k1 by A43,A44,Th14,A46,A27,A45,A48,Th16;
A53:    k in dom SP & k in dom Sp by A23,A39,A16,FINSEQ_3:25;
A54:    k< k1 by NAT_1:13;
A55:    Sp/.k < Sp/.f by A43,A44,Th14,A49,A45,Th16,A27,A53,A54;
        then
A56:    k<>f;
        per cases;
        suppose k <=f;
          then k < f by A56,XXREAL_0:1;
          then k1<=f & k1<>f by A52,NAT_1:13;
          then k1 < f by XXREAL_0:1;
          hence thesis by A52,A43,A27,Th16;
        end;
        suppose k > f;
          hence thesis by A55,A43,A53,Th16;
        end;
      end;
A57:  rng (SP|k1) = rng (SP|k) \/ rng  <*SP.k1*> by A26,FINSEQ_1:31
        .= rng (SP|k) \/ {SP.k1} by FINSEQ_1:38;
A58:  SpEk = SP.k1
      proof
        assume SpEk <> SP.k1;
        then SpEk in rng (SP|k) by A50,A57,ZFMISC_1:136;
        then consider w be object such that
A59:    w in dom (SP|k) & (SP|k).w = SpEk by FUNCT_1:def 3;
        reconsider w as Nat by A59;
A60:    1<= w<= k by A24,FINSEQ_3:25,A59;
        then w < len Sp by A23,XXREAL_0:2;
        then
A61:      w in dom Sp & w in dom SP by A16,A60,FINSEQ_3:25;
A62:    SP/.w = Sp/.w bag_extend 0 by A39,A20,A21,NAT_1:13,A60;
A63:    SP/.w = SP.w = (SP|k).w = SpEk by A59,A60,A61,PARTFUN1:def 6,
          FINSEQ_3:112;
        w<k1 by A60,NAT_1:13;
        then Sp/.w bag_extend 0  < Sp/.k1 bag_extend 0 by A27,A61,Th14,Th16;
        hence thesis by A62,A63;
      end;
      per cases by A22,XXREAL_0:1;
      suppose i <k1;
        then i<=k by NAT_1:13;
        hence thesis by A22,A20,A21,NAT_1:13,A39;
      end;
      suppose i = k1;
        hence SP/.i = Sp/.i bag_extend 0 by A58,A27,PARTFUN1:def 6;
      end;
    end;
  end;
  for k holds P[k] from NAT_1:sch 2(A18,A19);
  hence thesis;
end;
