Oscar.jl icon indicating copy to clipboard operation
Oscar.jl copied to clipboard

Addition of ideals fails

Open HechtiDerLachs opened this issue 3 years ago • 3 comments

Try running the following code:

R, (x,y) = QQ["x", "y"]
S, (u,v) = R["u", "v"]
I = ideal(S, [u]) + ideal(S, [v])

Addition of ideals is not possible due to some (certainly unnecessary) calls to Singular.

HechtiDerLachs avatar Feb 07 '22 09:02 HechtiDerLachs

Actually the last line is executed just fine. What doesn't work is printing the result:

julia> R, (x,y) = QQ["x", "y"]
(Multivariate Polynomial Ring in x, y over Rational Field, fmpq_mpoly[x, y])

julia> S, (u,v) = R["u", "v"]
(Multivariate Polynomial Ring in u, v over Multivariate Polynomial Ring in x, y over Rational Field, AbstractAlgebra.Generic.MPoly{fmpq_mpoly}[u, v])

julia> I = ideal(S, [u]) + ideal(S, [v]);

julia> typeof(I)
MPolyIdeal{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}

julia> typeof(ideal(S, [u]))
MPolyIdeal{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}

julia> I
Error showing value of type MPolyIdeal{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}:
ERROR: TypeError: in typeassert, expected fmpq_mpoly, got a value of type Singular.spoly{Singular.n_Q}
Stacktrace:
  [1] Ring
    @ ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:441 [inlined]
  [2] (::AbstractAlgebra.Generic.MPolyRing{fmpq_mpoly})(f::Singular.spoly{Singular.n_RingElem{Singular.spoly{Singular.n_Q}}})
    @ Oscar ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:246
  [3] getindex(A::Oscar.BiPolyArray{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}, #unused#::Val{:O}, i::Int64)
    @ Oscar ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:204
  [4] iterate
    @ ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:221 [inlined]
  [5] iterate
    @ ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:218 [inlined]
  [6] copyto!(dest::Vector{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}, src::Oscar.BiPolyArray{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}})
    @ Base ./abstractarray.jl:896
  [7] _collect
    @ ./array.jl:715 [inlined]
  [8] collect
    @ ./array.jl:709 [inlined]
  [9] expressify(a::MPolyIdeal{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}}; context::Nothing)
    @ Oscar ~/Projekte/OSCAR/Oscar.spielwiese/src/Rings/mpoly.jl:491
 [10] show_via_expressify(io::IOContext{Base.TTY}, mi::MIME{Symbol("text/plain")}, obj::Any; context::Nothing)
    @ AbstractAlgebra.PrettyPrinting ~/Projekte/OSCAR/AbstractAlgebra.jl/src/PrettyPrinting.jl:78
 [11] show_via_expressify
    @ ~/Projekte/OSCAR/AbstractAlgebra.jl/src/PrettyPrinting.jl:78 [inlined]
 [12] show(io::IOContext{Base.TTY}, mi::MIME{Symbol("text/plain")}, x::MPolyIdeal{AbstractAlgebra.Generic.MPoly{fmpq_mpoly}})
...

fingolfin avatar Feb 07 '22 23:02 fingolfin

That's weird. Because where the error originally occurred, I didn't have any printing going on. Either way: It tries to print from a Singular polynomial, which is probably not the correct thing to do.

HechtiDerLachs avatar Feb 08 '22 09:02 HechtiDerLachs

No, it is not trying to print a Singular polynomial. The problem is that the print function tries to iterate over I.gens, which tries to call some conversion function. It is another manifestation from the current singular_ring design limitations and bugs, see #975, #976.

thofma avatar Feb 08 '22 16:02 thofma

@HechtiDerLachs I don't get this error anymore in the newest Oscar. Can we close the issue?

julia> R, (x,y) = QQ["x", "y"]
(Multivariate Polynomial Ring in x, y over Rational Field, fmpq_mpoly[x, y])

julia> S, (u,v) = R["u", "v"]
(Multivariate Polynomial Ring in u, v over Multivariate Polynomial Ring in x, y over Rational Field, AbstractAlgebra.Generic.MPoly{fmpq_mpoly}[u, v])                                                                                             

julia> I = ideal(S, [u]) + ideal(S, [v])
ideal(u, v)

YueRen avatar Apr 05 '23 19:04 YueRen

If this error doesn't persist, we can close it, yes.

HechtiDerLachs avatar Apr 06 '23 09:04 HechtiDerLachs

Then I will close the issue. The Oscar <-> Singular interface is not perfect (yet), but this is an issue it doesn't have (anymore).

YueRen avatar Apr 06 '23 13:04 YueRen