oscar-system / Oscar.jl

A comprehensive open source computer algebra system for computations in algebra, geometry, and number theory.
https://www.oscar-system.org
Other
343 stars 126 forks source link

`absolute_primary_decomposition` fails for unit ideals #4039

Closed oskarhenriksson closed 1 month ago

oskarhenriksson commented 2 months ago

The expected behaviour when running absolute_primary_decomposition for the unit ideal is to get an empty vector back, like this:

julia> R, (x,y) = polynomial_ring(QQ,["x","y"])
(Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y])

julia> I = ideal([R(1)])
Ideal generated by
  1

julia> absolute_primary_decomposition(I)
Tuple{MPolyIdeal{QQMPolyRingElem}, MPolyIdeal{QQMPolyRingElem}, MPolyIdeal{AbstractAlgebra.Generic.MPoly{AbsSimpleNumFieldElem}}, Int64}[] 

However, for many cases where you have a unit ideal that is not just defined by 1, something seems to go wrong in the interface between Julia and Singular. For instance:

julia> R, (x,y) = polynomial_ring(QQ,["x","y"])
(Multivariate polynomial ring in 2 variables over QQ, QQMPolyRingElem[x, y])

julia> I = ideal([x+1,y+1,y])
Ideal generated by
  x + 1
  y + 1
  y

julia> absolute_primary_decomposition(I)
   skipping text from `)` error at token `)`
ERROR: `string`(@newvar) = `poly` is not supported
expected `string` = `string`
error occurred in or before primdec.lib::absPrimdecGTZ_i line 5840: `  string @newvar=@L[1][3];`
expected string-expression. type 'help string;'
leaving primdec.lib::absPrimdecGTZ_i (5835)

Stacktrace:
 [1] call_singular_library_procedure
   @ ~/.julia/packages/CxxWrap/5IZvn/src/CxxWrap.jl:624 [inlined]
 [2] low_level_caller_rng(lib::String, name::String, ring::Singular.PolyRing{…}, args::Singular.sideal{…})
   @ Singular ~/.julia/packages/Singular/A4riV/src/caller.jl:379
 [3] absPrimdecGTZ(ring::Singular.PolyRing{Singular.n_Q}, args::Singular.sideal{Singular.spoly{Singular.n_Q}})
   @ Singular.LibPrimdec ~/.julia/packages/Singular/A4riV/src/Meta.jl:45
 [4] __compute_absolute_primary_decomposition__(I::MPolyIdeal{QQMPolyRingElem})
   @ Oscar ~/.julia/dev/Oscar/src/Rings/mpoly-ideals.jl:906
 [5] #336
   @ ~/.julia/packages/AbstractAlgebra/tABFQ/src/Attributes.jl:357 [inlined]
 [6] get!(default::Oscar.var"#336#339"{MPolyIdeal{QQMPolyRingElem}}, h::Dict{Symbol, Any}, key::Symbol)
   @ Base ./dict.jl:479
 [7] get_attribute!
   @ ~/.julia/packages/AbstractAlgebra/tABFQ/src/Attributes.jl:230 [inlined]
 [8] absolute_primary_decomposition(I::MPolyIdeal{QQMPolyRingElem})
   @ Oscar ~/.julia/dev/Oscar/src/Rings/mpoly-ideals.jl:901
 [9] top-level scope
   @ REPL[17]:1
Some type information was truncated. Use `show(err)` to see complete types.

More specifically, the error seems to occur in line 906 of mpoly-ideals.jl, where absPrimdecGTZ is run:

julia> Singular.LibPrimdec.absPrimdecGTZ(Oscar.singular_polynomial_ring(I), Oscar.singular_generators(I))¨
   skipping text from `)` error at token `)`
ERROR: `string`(@newvar) = `poly` is not supported
expected `string` = `string`
error occurred in or before primdec.lib::absPrimdecGTZ_i line 5840: `  string @newvar=@L[1][3];`
expected string-expression. type 'help string;'
leaving primdec.lib::absPrimdecGTZ_i (5835)

Stacktrace:
 [1] call_singular_library_procedure
   @ ~/.julia/packages/CxxWrap/5IZvn/src/CxxWrap.jl:624 [inlined]
 [2] low_level_caller_rng(lib::String, name::String, ring::Singular.PolyRing{…}, args::Singular.sideal{…})
   @ Singular ~/.julia/packages/Singular/A4riV/src/caller.jl:379
 [3] absPrimdecGTZ(ring::Singular.PolyRing{Singular.n_Q}, args::Singular.sideal{Singular.spoly{Singular.n_Q}})
   @ Singular.LibPrimdec ~/.julia/packages/Singular/A4riV/src/Meta.jl:45
 [4] top-level scope
   @ REPL[48]:1
Some type information was truncated. Use `show(err)` to see complete types.

This bug was discovered together with @nachogm97.

joschmitt commented 2 months ago

I can reproduce this in plain Singular:

> ring R = 0, (x, y), dp;                                                                      
> ideal I = x + 1, y + 1, y;                                                                   
> LIB "primdec.lib";                                                                                     
> absPrimdecGTZ(I);                                                                            
   ? `string`(@newvar) = `poly` is not supported                                               
   ? expected `string` = `string`                                                              
   ? error occurred in or before primdec.lib::absPrimdecGTZ_i line 5849: `  string @newvar=@L[1
][3];`                                                                                         
   ? expected string-expression. type 'help string;'                                           
   ? leaving primdec.lib::absPrimdecGTZ_i (5844)                                               
   skipping text from `)` error at token `)`                                                   
   ? leaving primdec.lib::absPrimdecGTZ (5756)                                                 

@hannes14

hannes14 commented 2 months ago

fixed in Singular with https://github.com/Singular/Singular/commit/039ba5718696de895b1111dfdc315d88c93991ea