"Source: Text/Commut/Ideal.text";
"Line: 1050";
"Date: Thu Sep 25 14:47:46 2025";
"Main: Fri Sep 26 14:29:19 2025";
// original file: Text/Commut/Ideal.text, line: 1050
// Example: H116E7 ()
print "Example: H116E7";
ei := GetEchoInput();
SetEchoInput(true);
function ZRadical(I)
    // Find radical of zero dimensional ideal I
    P := Generic(I);
    n := Rank(P);
    G := UnivariateEliminationIdealGenerators(I);
    N := {};

    for i := 1 to n do
        // Set FF to square-free part of the i-th univariate
        // elimination ideal generator
        F := G[i];
        FF := F;
        while true do
            D := GCD(FF, Derivative(FF, 1, i));
            if D eq 1 then
                break;
            end if;
            FF := FF div D;
        end while;
        // Include FF in N if FF is a proper divisor of F
        if FF ne F then
            Include(~N, FF);
        end if;
    end for;

    // Return the sum of I and N
    if #N eq 0 then
      return I;
    else
      return ideal<P | I, N>;
    end if;
end function;
P<x, y, z> := PolynomialRing(RationalField(), 3);
I := ideal<P | (x+1)^3*y^4, x*(y-z)^2+1, z^3-z^2>;
R := ZRadical(I);     
Groebner(I);
Groebner(R);
I;
R;
I subset R;
assert $1;
R subset I;
assert not $1;
IsInRadical(x + 1, I);
assert $1;
SetEchoInput(ei);
