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

theorem Th25:
  for O being Ordinal,
      L being Abelian right_zeroed add-associative right_complementable
        well-unital distributive commutative associative non trivial
        doubleLoopStr,
      p being Polynomial of O,L,
      x being Function of O, L
   for perm being Permutation of O holds
     eval(p,x) = eval(p permuted_by perm,x*perm")
proof
  let O be Ordinal, L be Abelian right_zeroed add-associative
  right_complementable
  well-unital distributive commutative associative non trivial doubleLoopStr,
  p be Polynomial of O,L,
  x be Function of O, L;
  let perm be Permutation of O;
  set SB=SgmX(BagOrder O, Support p);
  consider y be FinSequence of L such that
A1: len y = len SB & eval(p,x) = Sum y and
A2: for i be Element of NAT st 1 <= i & i <= len y holds
  y/.i = (p * SB)/.i * eval((SB/.i),x) by POLYNOM2:def 4;
A3:BagOrder O linearly_orders Support p by POLYNOM2:18;
A4:SB is one-to-one & len SB = card Support p
    by PRE_POLY:10,11,POLYNOM2:18;
A5:rng SB = Support p by A3,PRE_POLY:def 2;
  set P=p permuted_by perm;
  defpred R[bag of O,bag of O] means $2 = $1*perm";
A6:for x be Element of Bags O ex y be Element of Bags O st R[x,y]
  proof
    let x be Element of Bags O;
    x*perm" in Bags O by PRE_POLY:def 12;
    hence thesis;
  end;
  consider f be Function of Bags O,Bags O such that
A7:for x be Element of Bags O holds R[x,f.x] from FUNCT_2:sch 3(A6);
A8:dom f= Bags O by FUNCT_2:52;
  rng perm = O =dom perm by FUNCT_2:52,def 3;
  then
A9: perm*perm" = id O = perm"*perm by FUNCT_1:39;
A10:f is one-to-one
  proof
    let x1,x2 be object such that
A11:x1 in dom f & x2 in dom f & f.x1=f.x2;
    reconsider x1,x2 as Element of Bags O by A11;
A12: f.x1 = x1*perm" & f.x2 = x2*perm" by A7;
A13:dom x1=O =dom x2 by PARTFUN1:def 2;
A14:(x1*perm")*perm = x1*(id O) by A9,RELAT_1:36
    .= x1 by A13,RELAT_1:51;
    (x2*perm")*perm = x2*(id O) by A9,RELAT_1:36
    .= x2 by A13,RELAT_1:51;
    hence thesis by A11,A12,A14;
  end;
  reconsider fSB = f*SB as one-to-one FinSequence of Bags O by A4,A10;
  rng SB c= dom f by A8;
  then
A15: dom fSB = dom SB by RELAT_1:27;
A16:rng fSB c= Support P
  proof
    let y be object such that
A17: y in rng fSB;
    consider x be object such that
A18:  x in dom fSB & fSB.x=y by FUNCT_1:def 3,A17;
A19:y = f.(SB.x) & x in dom SB & SB.x in dom f by A18,FUNCT_1:11,12;
    then reconsider SBx =SB.x as Element of Bags O;
    SBx in Support p by A19,A5,FUNCT_1:def 3;
    then SBx*perm" in Support P by Th22;
    hence thesis by A7,A19;
  end;
  Support P c= rng fSB
  proof
    let y be object such that
A20:y in Support P;
    reconsider y as Element of Bags O by A20;
A21:dom y=O by PARTFUN1:def 2;
A22:y*perm in Support p by A20,Th21;
    then
A23: f.(y*perm) = y*perm*perm" by A7
    .= y*(id O) by A9,RELAT_1:36
    .= y by A21,RELAT_1:51;
    consider w be object such that
A24: w in dom SB & SB.w=y*perm by A5,A22,FUNCT_1:def 3;
    w in dom fSB & fSB.w =y by A8,A22,A23,A24,FUNCT_1:11,13;
    hence thesis by FUNCT_1:def 3;
  end;
  then  consider z be FinSequence of L such that
A25:  len z = card Support P & eval(P,x*perm") = Sum z and
A26:   for i be Nat st 1 <= i & i <= len z holds
        z/.i = (P * fSB)/.i * eval(fSB/.i,x*perm") by A16,XBOOLE_0:def 10,Th24;
A27: len y = len z by A1,A4,A25,Th23;
  for i be Nat st 1<=i<=len y holds y.i=z.i
  proof
    let i be Nat such that
A28:1<=i<=len y;
A29:i in NAT by ORDINAL1:def 12;
A30:i in dom y & i in dom z & i in dom SB by A28,A1,FINSEQ_3:25,A27;
    then
A31: SB.i = SB/.i by PARTFUN1:def 6;
    then reconsider SBi=SB.i as Element of Bags O;
A32:dom SBi=O by PARTFUN1:def 2;
A33:SBi*perm"*perm = SBi*(id O) by A9,RELAT_1:36
    .= SBi by A32,RELAT_1:51;
    dom p = Bags O =dom P by FUNCT_2:def 1;
    then rng SB c= dom p & rng fSB c= dom P;
    then
A34: dom (p * SB) = dom SB & dom (P * fSB) = dom fSB by RELAT_1:27;
    then
A35:(P * fSB)/.i = (P * fSB).i by A15,A28,FINSEQ_3:25,A1,PARTFUN1:def 6
    .= P.(fSB.i) by A1,A15,A28,FINSEQ_3:25,A34,FUNCT_1:12
    .= P.(f.SBi) by A15,A28,FINSEQ_3:25,A1,FUNCT_1:12
    .= P.(SBi*perm") by A7
    .= p.(SBi*perm"*perm) by Def4
    .= (p*SB).i by A28,A1,A33,FINSEQ_3:25,A34,FUNCT_1:12
    .= (p*SB)/.i by A34,A28,A1,FINSEQ_3:25,PARTFUN1:def 6;
A36: (SB/.i)*perm" = f.SBi by A7,A31
    .=fSB.i by A15,A28,A1,FINSEQ_3:25,FUNCT_1:12
    .=fSB/.i by A15,A28,A1,FINSEQ_3:25,PARTFUN1:def 6;
    thus y.i = y/.i by A30,PARTFUN1:def 6
    .= (p * SB)/.i * eval(SB/.i,x) by A29,A2,A28
    .= (P * fSB)/.i * eval(fSB/.i,x*perm") by A35,A36,Th20
    .= z/.i by A26,A28,A27
    .= z.i by A30,PARTFUN1:def 6;
  end;
  hence thesis by FINSEQ_1:14,A1,A4,A25,Th23;
end;
