
theorem simpAgcd:
for F being Field
for S1,S2 being non empty finite Subset of F
for p1 being Ppoly of F,S1
for p2 being Polynomial of F
st S2 = S1 /\ (Roots p2) holds p1 gcd p2 is Ppoly of F,S2
proof
let F be Field, S1,S2 be non empty finite Subset of F;
let p1 be Ppoly of F,S1; let p2 be Polynomial of F;
assume AS: S2 = S1 /\ (Roots p2);
defpred P[Nat] means
    for S1,S2 being non empty finite Subset of F
    for p1 being Ppoly of F,S1
    for p2 being Polynomial of F
    st card S2 = $1 & S2 = S1 /\ (Roots p2) holds p1 gcd p2 is Ppoly of F,S2;
A: P[0];
B: P[1]
   proof
   now let S1,S2 be non empty finite Subset of F;
     let p1 be Ppoly of F,S1; let p2 be Polynomial of F;
     assume B1: card S2 = 1 & S2 = S1 /\ (Roots p2); then
     consider a being object such that B2: S2 = {a} by CARD_2:42;
     a in {a} by TARSKI:def 1; then
     reconsider a as Element of F by B2;
     set q = rpoly(1,a);
     B3: q divides p1
         proof
         C1: Roots p1 = S1 by RING_5:63;
         a in S2 by B2,TARSKI:def 1; then
         a in Roots p1 by B1,C1,XBOOLE_0:def 4; then
         a is_a_root_of p1 by POLYNOM5:def 10; then
         consider s being Polynomial of F such that
         C2: p1 = rpoly(1,a) *' s by HURWITZ:33;
         thus q divides p1 by C2,RING_4:1;
         end;
     B4: q divides p2
         proof
         a in S2 by B2,TARSKI:def 1; then
         a in Roots p2 by B1,XBOOLE_0:def 4; then
         a is_a_root_of p2 by POLYNOM5:def 10; then
         consider s being Polynomial of F such that
         C2: p2 = rpoly(1,a) *' s by HURWITZ:33;
         thus q divides p2 by C2,RING_4:1;
         end;
     now let r be Polynomial of F;
         assume C1: r divides p2 & r divides p1;
         consider s1 being Polynomial of F such that
         F1: p1 = r *' s1 by C1,RING_4:1;
         consider s2 being Polynomial of F such that
         F2: p2 = r *' s2 by C1,RING_4:1;
         per cases;
         suppose r is constant; then
           deg r <= 0 by RATFUNC1:def 2; then
           reconsider r1 = r as
              constant Element of the carrier of Polynom-Ring F
              by RING_4:def 4,POLYNOM3:def 10;
           consider b being Element of F such that
           C2: r1 = b|F by RING_4:20;
           C3: r = b * (1_.(F)) by C2,RING_4:16;
           C4: b <> 0.F by F1,C2;
           (b * (1_.(F))) *' (b" * q)
              = b" * ((b * (1_.(F))) *' q) by RING_4:10
             .= b" * (b * ((1_.(F)) *' q)) by RING_4:10
             .= (b" * b) * ((1_.(F)) *' q) by RING_4:11
             .= (1.F) * q by C4,VECTSP_1:def 10
             .= q;
           hence r divides q by C3,RING_4:1;
           end;
         suppose r is non constant; then
         G6: deg r > 0 by RATFUNC1:def 2; then
         reconsider r1 = r as non constant Element of
           the carrier of Polynom-Ring F by RING_4:def 4,POLYNOM3:def 10;
         set r1N = NormPolynomial r1;
         G4: r1 <> 0_.(F); then
         G1: len r1 <> 0 & LC r <> 0.F by POLYNOM4:5;
         len r1 = len r1N by G4,POLYNOM5:57,POLYNOM4:5; then
         deg r1N = len r1 - 1 by HURWITZ:def 2 .= deg r by HURWITZ:def 2;
         then reconsider r1Np = r1N as non constant monic Polynomial of F
           by G6,RATFUNC1:def 2;
         G5: r1Np = (LC r1)" * r by RING_4:23;
         r1Np *' ((LC r) * s1) = (LC r) * (r1Np *' s1) by RING_4:10
            .= ((LC r) * ((LC r1)" * r)) *' s1 by G5,RING_4:10
            .= (((LC r) * (LC r1)") * r) *' s1 by RING_4:11
            .= ((1.F) * r) *' s1 by G1,VECTSP_1:def 10
            .= p1 by F1; then
         consider S3 being non empty finite Subset of F such that
         C2: r1Np is Ppoly of F,S3 & S3 c= S1 by RING_4:1,simpAgcd1;
         G2: r1Np *' ((LC r) * s2) = (LC r) * (r1Np *' s2) by RING_4:10
            .= ((LC r) * ((LC r1)" * r)) *' s2 by G5,RING_4:10
            .= (((LC r) * (LC r1)") * r) *' s2 by RING_4:11
            .= ((1.F) * r) *' s2 by G1,VECTSP_1:def 10
            .= p2 by F2;
         now assume H: S3 <> {a};
           now assume D0: not a in S3;
             consider b being Element of F such that
             D1: b is_a_root_of r1Np by C2,POLYNOM5:def 8;
             b is_a_root_of r1 by G1,D1,POLYNOM5:59; then
             b is_a_root_of p1 by F1,ro1; then
             b in Roots p1 by POLYNOM5:def 10; then
             E: b in S1 by RING_5:63;
             b is_a_root_of p2 by G2,D1,ro1; then
             b in Roots p2 by POLYNOM5:def 10; then
             D2: b in S2 by B1,E;
             b in Roots r1Np by D1,POLYNOM5:def 10; then
             b <> a by D0,C2,RING_5:63;
             hence contradiction by D2,B2,TARSKI:def 1;
             end; then
           C6: {a} c= S3 by TARSKI:def 1;
           now assume G: not(ex b being Element of F st b in S3 & b <> a);
              now let o be object;
                assume J: o in S3; then
                reconsider c = o as Element of F;
                c = a by G,J;
                hence o in {a} by TARSKI:def 1;
                end;
              then S3 c= {a};
              hence contradiction by H,C6;
              end; then
           consider b being Element of F such that
           C3: b in S3 & b <> a;
           not b in S2 by B2,C3,TARSKI:def 1; then
           not b in Roots p2 by C2,C3,B1; then
           C5: not b is_a_root_of p2 by POLYNOM5:def 10;
           now assume r1Np divides p2; then
             consider s being Polynomial of F such that
             C6: p2 = r1Np *' s by RING_4:1;
             eval(r1Np,b) = 0.F by C2,C3,RING_5:62; then
             eval(p2,b) = 0.F * eval(s,b) by C6,POLYNOM4:24 .= 0.F;
             hence contradiction by C5,POLYNOM5:def 7;
             end;
           hence contradiction by G2,RING_4:1;
           end; then
         C9: q = (1_.(F)) *' r1Np by C2,simpAgcd2;
         r *' ((LC r)" * (1_.(F)))
            = (LC r)" * (r *' (1_.(F))) by RING_4:10
           .= q by RING_4:23,C9;
         hence r divides q by RING_4:1;
         end;
         end; then
     q = p1 gcd p2 by B3,B4,RING_4:53;
     hence p1 gcd p2 is Ppoly of F,S2 by B2,RING_5:57;
     end;
   hence thesis;
   end;
C: now let k be Nat;
   assume D0: P[k];
   now let S1,S2 be non empty finite Subset of F;
     let p1 be Ppoly of F,S1; let p2 be Polynomial of F;
     assume D1: card S2 = k + 1 & S2 = S1 /\ (Roots p2);
     set a = the Element of S2;
     D2: a in S1 & a in Roots p2 by D1,XBOOLE_0:def 4;
     reconsider S3 = S2 \ {a} as finite Subset of F;
         now let o be object;
           assume o in {a}; then
           o = a by TARSKI:def 1;
           hence o in S2;
           end; then
     D6: {a} c= S2; then
     D3: S2 = S3 \/ {a} by XBOOLE_1:45;
         a in {a} by TARSKI:def 1; then
         not a in S3 by XBOOLE_0:def 5; then
     D4: card S2 = card S3 + 1 by D3,CARD_2:41;
     per cases;
     suppose S3 is empty;
       hence p1 gcd p2 is Ppoly of F,S2 by B,D1,D4;
       end;
     suppose S3 is non empty;
       then reconsider S3 as non empty finite Subset of F;
         now assume D5: S1 \ {a} is empty;
         I: S1 = {a}
            proof
            now let o be object;
              assume o in {a}; then
              o = a by TARSKI:def 1;
              hence o in S1 by D1,XBOOLE_0:def 4;
              end; then
            D6: {a} c= S1;
            now let o be object;
              assume H: o in S1; then
              reconsider b = o as Element of F;
              now assume b <> a;
                then not b in {a} by TARSKI:def 1;
                hence contradiction by D5,H,XBOOLE_0:def 5;
                end;
              hence o in {a} by TARSKI:def 1;
              end; then
            S1 c= {a};
            hence thesis by D6;
            end;
         S2 = {a}
            proof
            S2 c= {a} by I,D1,XBOOLE_0:def 4;
            hence thesis by D6;
            end; then
         card S2 = 1 by CARD_2:42; then
         card S3 = 0 by D4;
         hence contradiction;
         end; then
       reconsider S4 = S1 \ {a} as non empty finite Subset of F;
         {a} c= S1 by D2,TARSKI:def 1; then
       E1: S1 = S4 \/ {a} by XBOOLE_1:45;
       Roots p1 = S1 by RING_5:63; then
       a is_a_root_of p1 by D2,POLYNOM5:def 10; then
       consider p1a being Polynomial of F such that
       D5: p1 = rpoly(1,a) *' p1a by HURWITZ:33;
       now assume p1a is constant; then
         deg p1a <= 0 by RATFUNC1:def 2; then
         reconsider r = p1a as
              constant Element of the carrier of Polynom-Ring F
              by RING_4:def 4,POLYNOM3:def 10;
         consider b being Element of F such that
         D6: r = b|F by RING_4:20;
         1.F = LC p1a by D5,ZZ3y,RATFUNC1:def 7 .= b by D6,RING_5:6;
         then p1a = 1_.(F) by D6,RING_4:14;
         then {a} = Roots p1 by D5,RING_5:18
                 .= S1 by RING_5:63;
         then S1 \ ({a} \/ {}) = {} by XBOOLE_1:46;
         then S4 is empty;
         hence contradiction;
         end; then
       reconsider p1a as Ppoly of F,S4 by D5,r59;
       a is_a_root_of p2 by D2,POLYNOM5:def 10; then
       consider p2a being Polynomial of F such that
       D6: p2 = rpoly(1,a) *' p2a by HURWITZ:33;
       per cases;
       suppose E0: S4 /\ (Roots p2a) is empty;
       S4 = Roots p1a by RING_5:63; then
       E2: p1a gcd p2a = 1_.(F) by E0,ZZ3;
       E4: Roots rpoly(1,a) = {a} by RING_5:18;
       E3: S2 = (S4 \/ {a}) /\ ({a} \/ (Roots p2a)) by D1,E1,E4,D6,UPROOTS:23
             .= (S4 /\ (Roots p2a)) \/ {a} by XBOOLE_1:24
             .= {a} by E0;
       p1 gcd p2 = rpoly(1,a) *' 1_.(F) by E2,D5,D6,ZZ2;
       hence p1 gcd p2 is Ppoly of F,S2 by E3,RING_5:57;
       end;
       suppose S4 /\ (Roots p2a) is non empty; then
       reconsider S5 = S4 /\ (Roots p2a) as non empty finite Subset of F;
       E2: Roots rpoly(1,a) = {a} by RING_5:18;
           a in {a} by TARSKI:def 1; then
           not a in S4 by XBOOLE_0:def 5; then
       E3: not a in S5 by XBOOLE_0:def 4;
       D10: now assume F1: {a} /\ S5 <> {};
            set o = the Element of {a} /\ S5;
            o in {a} & o in S5 by F1,XBOOLE_0:def 4; then
            a in S4 /\ (Roots p2a) by TARSKI:def 1; then
            a in S4 by XBOOLE_0:def 4; then
            not a in {a} by XBOOLE_0:def 5;
            hence contradiction by TARSKI:def 1;
            end;
       D9: {a} \/ S5
                = ({a} \/ S4) /\ ({a} \/ (Roots p2a)) by XBOOLE_1:24
               .= S2 by D1,E1,E2,D6,UPROOTS:23; then
       k + 1 = card(S5) + 1 by D1,E3,CARD_2:41; then
       D7: p1a gcd p2a is Ppoly of F,S5 by D0;
       D8: p1 gcd p2 = rpoly(1,a) *' (p1a gcd p2a) by D5,D6,ZZ2;
           rpoly(1,a) is Ppoly of F,{a} by RING_5:57;
       hence p1 gcd p2 is Ppoly of F,S2 by D10,D9,D7,D8,r58;
       end;
       end;
     end;
   hence P[k+1];
   end;
I: for k being Nat holds P[k] from NAT_1:sch 2(A,C);
consider n being Nat such that H: card S2 = n;
thus thesis by AS,I,H;
end;
