reserve k,m,n for Nat;
reserve R for commutative Ring,
        p,q for Polynomial of R,
        z0,z1 for Element of R;

theorem Th22:
  for L being Field
    for p being Polynomial of L holds
      even_part p = Subst(sieve(p,2),<% 0.L,0.L,1_L%>)
proof
  let L be Field;
  let p be Polynomial of L;
  set C=sieve (p,2),x2 = <% 0.L,0.L,1_L%>,Cx=Subst(C,x2), E= even_part p;
  consider F be FinSequence of Polynom-Ring L such that
  A1: Cx =  Sum F & len F = len C and
  A2: for n be Element of NAT st n in dom F holds
  F.n = C.(n-'1)*(x2`^(n-'1)) by POLYNOM5:def 6;
  consider f being sequence of Polynom-Ring L such that
  A3:Sum F = f.(len F) and
  A4:f.0 = 0.Polynom-Ring L & for j being Nat
  for v being Element of Polynom-Ring L st
  j < len F & v = F.(j + 1) holds f.(j + 1) = f.j + v
    by RLVECT_1:def 12;
  let n be Element of NAT;
  per cases;
    suppose A5:n is odd;
      defpred P[Nat] means $1 <= len F implies for P be Polynomial of L st
      P=f.$1 holds P.n=0.L;
      A6:P[0]
      proof
        assume 0 <= len F;
        let P be Polynomial of L;assume P=f.0;
        then P=0_.(L) by A4,POLYNOM3:def 10;
        hence P.n=0.L by FUNCOP_1:7;
      end;
      A7:P[k] implies P[k+1]
      proof
        assume A8:P[k];set k1=k+1;
        assume A9:k1 <= len F;
        let P be Polynomial of L such that A10:P=f.k1;
        A11: k1-'1 = k1-1 by NAT_1:11,XREAL_1:233;
        k1 in dom F by A9,NAT_1:11,FINSEQ_3:25;
        then A12:F.k1 = C.k*(x2`^k) by A11,A2;
        then reconsider Fk1=F.k1 as Element of Polynom-Ring L
          by POLYNOM3:def 10;
        reconsider fk=f.k as Polynomial of L by POLYNOM3:def 10;
        A13:P= f.k + Fk1 by A10,A9,NAT_1:13,A4
        .= fk + C.k*(x2`^k) by A12,POLYNOM3:def 10;
        A14: fk.n=0.L by A9,NAT_1:13,A8;
        n <> 2*k by A5;
        then (x2`^k).n =0.L by Th10;
        then (C.k*(x2`^k)).n = C.k * 0.L by POLYNOM5:def 4 .=0.L;
        then P.n =0.L+0.L by A13,A14,NORMSP_1:def 2;
        hence thesis;
      end;
      P[k] from NAT_1:sch 2(A6,A7);
      then Cx.n =0.L by A1,A3;
      hence thesis by A5,HURWITZ2:def 1;
    end;
    suppose A15: n is even;
      then consider m be Nat such that
      A16: 2*m=n by ABIAN:def 2;set m1=m+1;
      per cases;
      suppose A17:m < len F;
        defpred R[Nat] means $1 <= len F implies
          for P be Polynomial of L st P=f.$1 holds P.n=p.n;
        defpred P[Nat] means $1 <= m implies
          for P be Polynomial of L st P=f.$1 holds P.n=0.L;
        A18:P[0]
        proof
          assume 0 <= m;
          let P be Polynomial of L;assume P=f.0;
          then P=0_.(L) by A4,POLYNOM3:def 10;
          hence P.n=0.L by FUNCOP_1:7;
        end;
        A19:P[k] implies P[k+1]
        proof
          assume A20:P[k];set k1=k+1;
          assume A21:k1 <= m;
          then A22:k < m by NAT_1:13;
          let P be Polynomial of L such that A23:P=f.k1;
          A24: k1-'1 = k1-1 by NAT_1:11,XREAL_1:233;
          A25:k < len F & k1 <= len F by A22,A17,A21,XXREAL_0:2;
          then k1 in dom F by NAT_1:11,FINSEQ_3:25;
          then A26:F.k1 = C.k*(x2`^k) by A24,A2;
          then
          reconsider Fk1=F.k1 as Element of Polynom-Ring L by POLYNOM3:def 10;
          reconsider fk=f.k as Polynomial of L by POLYNOM3:def 10;
          A27:P= f.k + Fk1 by A23,A4,A25
          .= fk + C.k*(x2`^k) by A26,POLYNOM3:def 10;
          A28: fk.n=0.L by NAT_1:13,A20,A21;
          n <> 2*k by A16,A21,NAT_1:13;
          then (x2`^k).n =0.L by Th10;
          then (C.k*(x2`^k)).n = C.k * 0.L by POLYNOM5:def 4 .=0.L;
          then P.n =0.L+0.L by A27,A28,NORMSP_1:def 2;
          hence thesis;
        end;
        A29:P[k] from NAT_1:sch 2(A18,A19);
        A30:R[m1]
        proof
          assume A31: m1 <= len F;
          let P be Polynomial of L such that A32:P=f.m1;
          reconsider fm=f.m as Polynomial of L by POLYNOM3:def 10;
          A33:1<= m1 by NAT_1:11;
          A34: m1-'1 = m1-1 by NAT_1:11,XREAL_1:233;
          A35:F.m1 = C.m*(x2`^m) by A34,A2,A33,A31,FINSEQ_3:25;
          then reconsider Fm1=F.m1 as Element of Polynom-Ring L
          by POLYNOM3:def 10;
          A36:P= f.m + Fm1 by A32,A31,NAT_1:13,A4
          .= fm + C.m*(x2`^m) by A35,POLYNOM3:def 10;
          A37: fm.n=0.L by A29;
          (x2`^m).n =1_L by A16,Th10;
          then (C.m*(x2`^m)).n = C.m * 1_L by POLYNOM5:def 4
          .= C.m;
          then P.n =0.L+C.m by A36,A37,NORMSP_1:def 2;
          hence thesis by Def5,A16;
        end;
        A38:m1<=k & R[k] implies R[k+1]
        proof
          set k1=k+1;
          assume A39:m1<=k & R[k];
          assume A40:k1 <= len F;
          let P be Polynomial of L such that A41:P=f.k1;
          A42: k1-'1 = k1-1 by NAT_1:11,XREAL_1:233;
          k1 in dom F by A40,NAT_1:11,FINSEQ_3:25;
          then A43:F.k1 = C.k*(x2`^k) by A42,A2;
          then
          reconsider Fk1=F.k1 as Element of Polynom-Ring L by POLYNOM3:def 10;
          reconsider fk=f.k as Polynomial of L by POLYNOM3:def 10;
          A44:P= f.k + Fk1 by A41,A4,A40,NAT_1:13
          .= fk + C.k*(x2`^k) by A43,POLYNOM3:def 10;
          A45: fk.n=p.n by A40,NAT_1:13,A39;
          n <> 2*k by A16,A39,NAT_1:13;
          then (x2`^k).n =0.L by Th10;
          then (C.k*(x2`^k)).n = C.k * 0.L by POLYNOM5:def 4 .=0.L;
          then P.n =p.n+0.L by A44,A45,NORMSP_1:def 2;
          hence thesis;
        end;
        A46:m1<= k implies R[k] from NAT_1:sch 8(A30,A38);
        m1 <=len F by A17,NAT_1:13;
        then Cx.n = p.n by A1,A3,A46;
        hence thesis by A15,HURWITZ2:def 1;
      end;
      suppose A47: m >= len F;
        then A48: 2*m >= 2*len C by A1,XREAL_1:64;
        A49: len E is_at_least_length_of E by ALGSEQ_1:def 3;
        2*m >= len E
        proof
          per cases;
          suppose len E=0;
            hence thesis;
          end;
          suppose len E >0;
            then 2 * len C = len E+1 by Th18,Th20;
            hence thesis by A48,NAT_1:13;
          end;
        end;
        then A50:E.n =0.L by A16,ALGSEQ_1:def 2,A49;
        A51: len Cx is_at_least_length_of Cx by ALGSEQ_1:def 3;
        D: 2=2*1;
        2*m >= len Cx
        proof
          per cases;
          suppose len E=0;
            then len C=0 by D,Th21;
            then C=0_.L by POLYNOM4:5;
            then Cx = 0_.L by POLYNOM5:49;
            hence thesis by POLYNOM4:3;
          end;
          suppose len E >0;
            then 2 * len C = len E+1 by Th18,Th20;
            then A52: len C<>0;
            len x2 = 3 by NIVEN:28;
            then len Cx  = (len C)*3-(len C)-3+2 by A52,POLYNOM5:52
            .= (len C)*2 -1;
            then 2*m >= len Cx+1 by A47,A1,XREAL_1:64;
            hence thesis by NAT_1:13;
          end;
        end;
        hence thesis by A16,A50,ALGSEQ_1:def 2,A51;
      end;
    end;
end;
