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 Th35:
  for R be commutative associative
           Abelian right_zeroed add-associative right_complementable
           well-unital distributive non trivial doubleLoopStr
    for t be bag of O, p be Polynomial of O, R, i be object
      for x being Function of O, R st i in O holds
    eval(Subst(t,i,p),x) = eval(t, x+*(i,eval(p,x)))
proof
  let R be commutative associative
        Abelian right_zeroed add-associative right_complementable
        well-unital distributive non trivial doubleLoopStr;
  let t be bag of O, p be Polynomial of O, R, i be object;
  let x be Function of O, R such that
A1:i in O;
  set xE = x+*(i,eval(p,x));
  set P = p `^ (t.i), t0= t+*(i,0);
  set SS=SgmX(BagOrder O, Support P);
  set Smp = Subst(t,i,p);
  consider y be FinSequence of R such that
A2:  len y = len SS & eval(P,x) = Sum y and
A3:  for i be Element of NAT st 1 <= i & i <= len y holds
  y/.i = (P * SS)/.i * eval(SS/.i,x) by POLYNOM2:def 4;
  BagOrder O linearly_orders  Support P by POLYNOM2:18;
  then
A4: rng SS = Support P by PRE_POLY:def 2;
A5: SS is one-to-one by POLYNOM2:18,PRE_POLY:10;
  consider tran be one-to-one FinSequence of Bags O such that
A6:  rng tran = Support Smp and
A7:  len tran = len SS and
A8:  for j st 1 <= j <= len tran holds tran.j = Subst(t,i,SS/.j) by A4,A5,Th34;
A9: len tran = card Support Smp by A6,FINSEQ_4:62;
A10:card Support Smp = len SS by A6,FINSEQ_4:62,A7;
  consider Y be FinSequence of R such that
A11:len Y = card Support Smp & eval(Smp,x) = Sum Y and
A12:  for i being Nat st 1 <= i & i <= len Y holds
  Y/.i = (Smp * tran)/.i * eval(tran/.i,x) by A6,HILB10_2:24;
A13:dom (y * (eval(t0,x) )) = dom y by POLYNOM1:def 2;
  then
A14: len (y * (eval(t0,x))) = len y by FINSEQ_3:29;
A15: eval(P ,x) = (power R).( eval(p,x), (t.i)) by Th30;
  for j st 1 <= j & j <= len Y holds Y. j = (y * (eval(t0,x) )).j
  proof
    let j such that
A16:1 <= j & j <= len Y;
A17: j in NAT by ORDINAL1:def 12;
A18: len Y = len tran = len SS =len y by A2,A11,A6,FINSEQ_4:62,A7;
A19: rng tran c= Bags O by RELAT_1:def 19;
    dom P = Bags O =dom Smp by FUNCT_2:def 1;
    then
A20: dom (P * SS) = dom SS & dom (Smp * tran)= dom tran
      by A19,A4,RELAT_1:27;
A21: j in dom tran & j in dom SS & j in dom y & j in dom Y
      by A16,A2,A11,A7,A9,FINSEQ_3:25;
    then
A22:  tran/.j = tran.j = Subst(t,i,SS/.j) by A16,A8,A11,A9,PARTFUN1:def 6;
A23: (P * SS)/.j = (P * SS).j by A20,A16,A11,A10,FINSEQ_3:25,PARTFUN1:def 6
    .= P.(SS.j) by A20,A16,A11,A10,FINSEQ_3:25,FUNCT_1:12
    .= P.(SS/.j) by A21,PARTFUN1:def 6;
A24: (Smp * tran)/.j = (Smp * tran).j
    by A16,A11,A9,FINSEQ_3:25,A20,PARTFUN1:def 6
    .= Smp.(tran.j) by A16,A11,A9,FINSEQ_3:25,A20,FUNCT_1:12
    .= (P * SS)/.j by A23,Th33,A22;
    Y.j = Y/.j = (Smp * tran)/.j * eval(tran/.j,x)
      by A16,A12,A21,PARTFUN1:def 6;
    hence Y.j = ((P * SS)/.j * (eval(t0,x) * eval(SS/.j,x)))
      by A22,A24,POLYNOM2:16
    .= (((P * SS)/.j * eval(SS/.j,x)) *eval(t0,x)) by GROUP_1:def 3
    .= ((y/.j) *eval(t0,x)) by A17,A3,A18,A16
    .= (y * (eval(t0,x)))/.j by A21,POLYNOM1:def 2
    .= (y * (eval(t0,x))).j by A13,A16,A2,A11,A7,A9
    ,FINSEQ_3:25,PARTFUN1:def 6;
  end;
  then
A25: Y = (y * (eval(t0,x))) by A14,A2,A11,A6,FINSEQ_4:62,A7,FINSEQ_1:14;
  dom t= O by PARTFUN1:def 2;
  then
A26: t0.i = 0 by A1,FUNCT_7:31;
  dom x = O = dom xE by PARTFUN1:def 2;
  then
A27: xE/.i= xE.i = eval(p,x) by A1,FUNCT_7:31,PARTFUN1:def 6;
  (power R).(xE/.i, 0) = 1_R = 1.R by GROUP_1:def 7;
  then eval (t0,xE) * (power R).(xE/.i, t.i) = eval (t,xE)* 1.R by A1,Th17;
  hence eval (t,xE)=(power R).(eval(p,x), t.i) * eval(t0,x) by A26,Th18,A27
  .= eval(Smp,x) by A25,A15,A2,A11,POLYNOM1:13;
end;
