Skip to content

Comparison of polynomials from different rings throws inconsistently #4107

Open
@lkastner

Description

@lkastner

Describe the bug
When comparing polynomials from different rings I get inconsistent behaviour. Sometimes I just get false and sometimes an error.

To Reproduce

julia> R0,(x0) = polynomial_ring(QQ,1)
(Multivariate polynomial ring in 1 variable over QQ, QQMPolyRingElem[x1])

julia> R1,(x1) = polynomial_ring(ZZ,1)
(Multivariate polynomial ring in 1 variable over ZZ, ZZMPolyRingElem[x1])

julia> R2,(x2) = polynomial_ring(GF(2),1)
(Multivariate polynomial ring in 1 variable over GF(2), FqMPolyRingElem[x1])

julia> x0 == x1
false

julia> x0 == x2
false

julia> R3,(x3) = polynomial_ring(GF(3),1)
(Multivariate polynomial ring in 1 variable over GF(3), FqMPolyRingElem[x1])

julia> x2 == x3
ERROR: parents do not match
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] check_parent
   @ ~/.julia/packages/AbstractAlgebra/QjFtH/src/AbstractAlgebra.jl:208 [inlined]
 [3] check_parent
   @ ~/.julia/packages/AbstractAlgebra/QjFtH/src/AbstractAlgebra.jl:207 [inlined]
 [4] ==(a::FqMPolyRingElem, b::FqMPolyRingElem)
   @ Nemo ~/.julia/packages/Nemo/4P3uO/src/flint/fq_default_mpoly.jl:295
 [5] ==(A::Vector{FqMPolyRingElem}, B::Vector{FqMPolyRingElem})
   @ Base ./abstractarray.jl:2943
 [6] top-level scope
   @ REPL[18]:1

julia> x0 == x3
false

Expected behavior
We have many places where we first compare the "surrounding space" before comparing the actual objects. So I would expect an error to get thrown. E.g. try

cube(2) == cube(3)

Additional context
Maybe this needs a styleguide entry, I actually did not look it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions