reserve n for Nat;

theorem
for R being domRing,
    p being non constant Polynomial of R
holds card(BRoots p) = deg p iff
      ex a being Element of R, q being Ppoly of R st p = a * q
proof
let R be domRing, p be non constant Polynomial of R;
per cases;
suppose p is with_roots;
  then reconsider p1 = p as non zero with_roots Polynomial of R;
  consider q being (Ppoly of R,BRoots p1),
           r being non with_roots Polynomial of R such that
  H: p1 = q *' r & Roots q = Roots p1 by acf;
  reconsider r1 = r as Element of the carrier of Polynom-Ring R
     by POLYNOM3:def 10;
  A: now assume A1: card(BRoots p) = deg p;
     r <> 0_.(R) & q <> 0_.(R); then
     deg p = deg q + deg r by H,HURWITZ:23
          .= card(BRoots q) + deg r by lemacf5
          .= deg p + deg r by A1,pf2;
     then r1 is constant;
     then consider a being Element of R such that B: r1 = a|R by RING_4:20;
     p = q *' (a * 1_.(R)) by H,B,RING_4:16
      .= a * (q *' 1_.(R)) by RATFUNC1:6
      .= a * q;
     hence ex a being Element of R, q being Ppoly of R st p = a * q;
     end;
  now assume ex a being Element of R, q being Ppoly of R st p = a * q;
    then consider a being Element of R, q being Ppoly of R such that
    A1: p = a * q;
    set B = BRoots q;
    reconsider q as Ppoly of R,B by lll;
    p <> 0_.(R); then A3: a is non zero by A1,POLYNOM5:26;
    hence deg p = deg q by A1,Th25
               .= card B by lemacf5 .= card(BRoots p) by A1,A3,llll;
    end;
  hence thesis by A;
  end;
suppose A: p is non with_roots;
  then reconsider p1 = p as non zero non with_roots Polynomial of R;
  card(BRoots p) = card(EmptyBag(the carrier of R)) by A,lemacf1
                   .= 0 by UPROOTS:11;
  hence thesis by A,RATFUNC1:def 2;
  end;
end;
