RFC: Maximal ideal in FriCAS

1 view
Skip to first unread message

Grégory Vanuxem

unread,
Jul 2, 2026, 7:51:12 PM (7 hours ago) Jul 2
to fricas...@googlegroups.com
Hello,

To continue, here is an implementation in PolynomialIdeal (file attached), to check if an ideal is maximal. I used Gemini first, checked its code manually (shape lemma for example that I didn't know), fixed 3 groebner basis computations to 1 computation for example, some improvements/issues remain I guess, and finally asked Claude to check the code. The algorithm is not totally deterministic for multi-variables (5 random attempts, Tschirnhaus) and uses the shape lemma that you should know. The rest is academic I think.

I assume it could be improved, and it might even contain some bugs. If you have any comments, improvements or fixes, I would be happy to read them.

Greg

     maximal?(I : Ideal, lvar : List VarSet) : Boolean ==
       element?(1, I) => false
       empty? lvar => empty? (groebner I).idl
       not zeroDim?(I, lvar) => false
       n : NNI := #lvar
       J := groebner I
       Jd := J.idl
       n = 1 =>
         empty? Jd => false
         g := Jd.first
         x := lvar.first
         deg := degree(univariate(g, x))
         deg = 0 => false
         deg = 1 => true
         if F has PolynomialFactorizationExplicit then -- TODO: implement for Nemo
           fl := factorList(factor(g)$DPoly)
           #fl = 1 and fl(1).exponent = 1
         else
           false
       x := lvar.last
       lv1 := remove(x, lvar)
       for attempt in 1..5 repeat
         if #Jd = n then
           ok : Boolean := true
           i : NNI := 1
           for f in Jd while ok repeat
             if i < n then
               if not isMonic?(f, lvar(i)) or degree(univariate(f, lvar(i))) ~= 1 then
                 ok := false
             i := i + 1
           if ok then
             g := Jd(n)
             deg := degree(univariate(g, x))
             deg = 0 => return false
             deg = 1 => return true
             if F has PolynomialFactorizationExplicit then
               fl := factorList(factor(g)$DPoly)
               return (#fl = 1 and fl(1).exponent = 1)
             else
               return false
         ranvals : List Z := [random(23)$Z for vv in lv1] -- use #lv1 ?
         val : DPoly := _+/[rv * (vv::DPoly) for vv in lv1 for rv in ranvals] + (x::DPoly)
         J := groebnerIdeal groebner [(univariate(p, x)).val for p in J.idl]
         Jd := J.idl
       false

     maximal?(I : Ideal) : Boolean == maximal?(I, "setUnion"/[variables g for g in I.idl])
ideal.spad
Reply all
Reply to author
Forward
0 new messages