Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for module ordering conversion #4312

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion experimental/IntersectionTheory/src/blowup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function present_finite_extension_ring(F::Oscar.AffAlgHom)
gJ = elem_type(FM)[FM([j==i ? x : R() for j in 1:g]) for x in gens(V) for i in 1:g]
U = vcat(gB, gJ)
S, _ = sub(FM, U)
P = groebner_basis(S, ordering = default_ordering(R)*lex(FM))
P = groebner_basis(S, ordering = default_ordering(R)*invlex(FM))
Rw, _ = grade(R, vcat(repeat([1], b), repeat([0], a)))
RtoRw = hom(R, Rw, gens(Rw))
inA = x -> x == zero(Rw) ? true : (degree(Int, leading_term(RtoRw(x)))) <= 0
Expand Down
3 changes: 2 additions & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ end

function singular_poly_ring(R::MPolyDecRing; keep_ordering::Bool = false)
if !keep_ordering
return singular_poly_ring(forget_decoration(R), default_ordering(R))
return singular_poly_ring(forget_decoration(R),
singular(default_ordering(R))*Singular.ordering_c())
end
return singular_poly_ring(forget_decoration(R); keep_ordering)
end
Expand Down
9 changes: 6 additions & 3 deletions src/Rings/mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -617,19 +617,22 @@ function singular_poly_ring(Rx::MPolyRing{T}; keep_ordering::Bool = false) where
if keep_ordering
return Singular.polynomial_ring(singular_coeff_ring(base_ring(Rx)),
_variables_for_singular(symbols(Rx)),
ordering = internal_ordering(Rx),
ordering = internal_ordering(Rx),
ordering2 = :comp1max,
cached = false)[1]
else
return Singular.polynomial_ring(singular_coeff_ring(base_ring(Rx)),
_variables_for_singular(symbols(Rx)),
ordering2 = :comp1max,
cached = false)[1]
end
end

function singular_poly_ring(Rx::MPolyRing{T}, ord::Symbol) where {T <: RingElem}
return Singular.polynomial_ring(singular_coeff_ring(base_ring(Rx)),
_variables_for_singular(symbols(Rx)),
ordering = ord,
ordering = ord,
ordering2 = :comp1max,
cached = false)[1]
end

Expand All @@ -643,7 +646,7 @@ end
function singular_poly_ring(Rx::MPolyRing{T}, ord::MonomialOrdering) where {T <: RingElem}
return Singular.polynomial_ring(singular_coeff_ring(base_ring(Rx)),
_variables_for_singular(symbols(Rx)),
ordering = singular(ord),
ordering = singular(ord)*Singular.ordering_c(),
cached = false)[1]
end

Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,7 @@ Note: This is only available for localizations at rational points.
F = free_module(R, length(Jlist))
Imax = ideal(R,gens(R))
M = sub(F,[F(syz_mod[i]) for i=1:Singular.ngens(syz_mod)])[1] + (Imax*F)[1]
oF = negdegrevlex(R)*invlex(F)
oF = negdegrevlex(R)*lex(F)
res_vec = typeof(gen(I,1))[]

## select by Nakayama
Expand Down
4 changes: 2 additions & 2 deletions src/Rings/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2154,8 +2154,8 @@ function _try_singular_easy(Q::order_conversion_ctx, o::Orderings.ModOrdering)
Q.has_c_or_C && return (false, Q.def)
Q.has_c_or_C = true
o.gens == 1:length(o.gens) || return (false, Q.def)
return o.ord == :lex ? (true, Singular.ordering_C(length(o.gens))) :
o.ord == :invlex ? (true, Singular.ordering_c(length(o.gens))) :
return o.ord == :lex ? (true, Singular.ordering_c(length(o.gens))) :
o.ord == :invlex ? (true, Singular.ordering_C(length(o.gens))) :
(false, Q.def)
end

Expand Down
4 changes: 2 additions & 2 deletions test/AlgebraicGeometry/Schemes/Tjurina.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end
@test is_contact_equivalent(L(x^5+y^4), L(x^5*y^4-3*x^5+y^5-y^4))
@test is_contact_equivalent(L(x^5+y^4), L(x^5-y^4))
@test is_contact_equivalent(L(x*y), L(x^2-y^2*(x-3)))
@test is_contact_equivalent(L(x^5+y^2), L(x^2-(x-y)^5))
@test is_contact_equivalent(L(x^5+y^2), L(x^2-(x-y)^5)) # if this test fails minimal_generating_set could be broken

## pos. char.
R, (x,y) = GF(5)[:x, :y]
Expand Down Expand Up @@ -223,7 +223,7 @@ end
R, (x,y,z) = QQ[:x, :y, :z]
L,_ = localization(R, complement_of_point_ideal(R, [0, 0, 0]))
@test is_contact_equivalent(zero(L), L(0//(x+1)))
@test is_contact_equivalent(L(x^2+y^2), L(y^2+z^2))
@test is_contact_equivalent(L(x^2+y^2), L(y^2+z^2)) # if this test fails minimal_generating_set is probably broken
@test !is_contact_equivalent(L(z^2), L(x^2+y^2))
@test !is_contact_equivalent(L(x^2+y^2), L(x^2+y^2-z^2))
end
Expand Down
23 changes: 23 additions & 0 deletions test/Modules/UngradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,29 @@ end
@test_throws ArgumentError groebner_basis(M)
end

#issue 4303
@testset "module ordering conversion to Singular" begin
R, (x,y) = polynomial_ring(QQ, [:x, :y])
F = free_module(R, 4)
g = F[1] + x*F[2] + x*F[3] + F[4]
M = SubquoModule(F, [g])

ord = lex(F)*deglex(R)
@test leading_term(g, ordering=ord) == F[1] #ordering is applied in Oscar
@test leading_module(M, ord) == SubquoModule(F, [F[1]]) #ordering is applied after conversion to Singular

ord = deglex(R)*lex(F)
@test leading_term(g, ordering=ord) == x*F[2]
@test leading_module(M, ord) == SubquoModule(F, [x*F[2]])

ord = deglex(R)*invlex(F)
@test leading_term(g, ordering=ord) == x*F[3]
@test leading_module(M, ord) == SubquoModule(F, [x*F[3]])

ord = invlex(F)*deglex(R)
@test leading_term(g, ordering=ord) == F[4]
@test leading_module(M, ord) == SubquoModule(F, [F[4]])
end

@testset "Test kernel" begin
Oscar.set_seed!(235)
Expand Down
4 changes: 2 additions & 2 deletions test/Rings/orderings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ end
O5 = invlex(gens(K))*degrevlex(gens(R))
@test monomial_ordering(R, singular(O5)) == degrevlex(gens(R))
@test length(string(O5)) > 2
@test string(singular(O5)) == "ordering_c() * ordering_dp(5)"
@test string(singular(O5)) == "ordering_C() * ordering_dp(5)"

a = matrix_ordering([x, y], matrix(ZZ, 2, 2, [1 2; 3 4]))
b = wdeglex([s, t, u], [1, 2, 3])
O6 = a * lex(gens(K)) * b
@test monomial_ordering(R, singular(O6)) == a * b
@test length(string(O6)) > 2
@test string(singular(O6)) == "ordering_M([1 2; 3 4]) * ordering_C() * ordering_Wp([1, 2, 3])"
@test string(singular(O6)) == "ordering_M([1 2; 3 4]) * ordering_c() * ordering_Wp([1, 2, 3])"

O7 = weight_ordering([-1,2,0,2,0], degrevlex(gens(R)))
@test monomial_ordering(R, singular(O7)) == O7
Expand Down
Loading