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 Th37:
  for R be commutative associative
           Abelian right_zeroed add-associative right_complementable
           well-unital distributive non trivial doubleLoopStr
    for p, s be Polynomial of O, R, i be object
      for x be Function of O, R st i in O holds
    eval(Subst(p,i,s),x) = eval(p, x+*(i,eval(s,x)))
proof
  let R be commutative associative
           Abelian right_zeroed add-associative right_complementable
           well-unital distributive non trivial doubleLoopStr;
  let p,s be Polynomial of O, R, i be object;
  let  x be Function of O, R such that
A1: i in O;
  set Sub = Subst(p,i,s), xE=x +* (i,eval(s,x)), B=SgmX(BagOrder O, Support p);
  consider f be FinSequence of R such that
A2: len f = len B & eval(p,xE) = Sum f and
A3:  for j be Element of NAT st 1 <= j & j <= len f holds
  f/.j = (p * B)/.j * eval(B/.j,xE) by POLYNOM2:def 4;
  consider S be FinSequence of Polynom-Ring (O, R) such that
A4:Subst(p,i,s) = Sum S & len B = len S and
A5: for j st j in dom S holds S.j = p.(B/.j) * Subst(B/.j,i, s) by Def4;
  for q be Polynomial of O,R,j st j in dom f & q = S.j holds f.j=eval(q,x)
  proof
    let q be Polynomial of O,R,j such that
A6: j in dom f & q = S.j;
A7: dom f = dom S =dom B by A2,A4,FINSEQ_3:29;
    then S.j = p.(B/.j) * Subst(B/.j,i, s) by A6,A5;
    then
A8: eval (q,x) = p.(B/.j) * eval (Subst(B/.j,i, s),x) by A6,POLYNOM7:29
    .= p.(B/.j) * eval (B/.j,xE) by Th35,A1;
    BagOrder O linearly_orders Support p by POLYNOM2:18;
    then
A9: rng B = Support p by PRE_POLY:def 2;
    dom p = Bags O by FUNCT_2:def 1;
    then dom (p * B) = dom B by A9,RELAT_1:27;
    then
A10:(p * B)/.j =(p * B).j = p.(B.j) & B/.j = B.j
    by A6,A7,PARTFUN1:def 6,FUNCT_1:13;
    1<=j & j <= len f & j in NAT by A6,FINSEQ_3:25;
    then f.j = f/.j = (p * B)/.j * eval(B/.j,xE) by A3,A6,PARTFUN1:def 6;
    hence thesis by A8,A10;
  end;
  hence thesis by A4,Th36,A2;
end;
