From 6491bc4a3662662eab6878d39c941aa03b2d4be6 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:40:46 +0100 Subject: [PATCH 01/11] fix conversion of module orderings from Oscar to Singular --- src/Rings/orderings.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rings/orderings.jl b/src/Rings/orderings.jl index 6f4ab817af08..7b6b18371a2e 100644 --- a/src/Rings/orderings.jl +++ b/src/Rings/orderings.jl @@ -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 From 557b1856742458a091a702a84ee2e9a80256cf78 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:02:03 +0100 Subject: [PATCH 02/11] added Test --- test/Modules/UngradedModules.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/Modules/UngradedModules.jl b/test/Modules/UngradedModules.jl index dc7223e275c7..468cd27cd63e 100644 --- a/test/Modules/UngradedModules.jl +++ b/test/Modules/UngradedModules.jl @@ -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) From 478e95d8c2965415b7fd608b1f13d67341248ebe Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:01:04 +0100 Subject: [PATCH 03/11] experimenting Changed default ModuleOrdering to match the default ordering on the Singular side --- src/Modules/UngradedModules/Methods.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Modules/UngradedModules/Methods.jl b/src/Modules/UngradedModules/Methods.jl index 822b9036ea85..30f06b810f03 100644 --- a/src/Modules/UngradedModules/Methods.jl +++ b/src/Modules/UngradedModules/Methods.jl @@ -233,9 +233,9 @@ ring_map(f::SubQuoHom) = f.ring_map function default_ordering(F::FreeMod) if !isdefined(F, :default_ordering) if iszero(F) - F.default_ordering = default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :lex)) + F.default_ordering = default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :invlex)) else - F.default_ordering = default_ordering(base_ring(F))*lex(gens(F)) + F.default_ordering = default_ordering(base_ring(F))*invlex(gens(F)) end end return F.default_ordering::ModuleOrdering{typeof(F)} From d80a5d3e68bc090728bc63652a9d654b11ecb5cc Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:30:46 +0100 Subject: [PATCH 04/11] Fixed wrong conversion test for ModuleOrderings --- test/Rings/orderings.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Rings/orderings.jl b/test/Rings/orderings.jl index 8fac041a8e28..c47a081dc195 100644 --- a/test/Rings/orderings.jl +++ b/test/Rings/orderings.jl @@ -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 From 57af1da4babb89154c2fe38797c261e194d0c930 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:38:32 +0100 Subject: [PATCH 05/11] adapt doctest to experimenting --- docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md index 382c07afd0fc..f7109041e8d3 100644 --- a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md +++ b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md @@ -70,7 +70,7 @@ julia> F = free_module(R, 2) Free module of rank 2 over R julia> default_ordering(F) -degrevlex([x, y, z])*lex([gen(1), gen(2)]) +degrevlex([x, y, z])*invlex([gen(1), gen(2)]) julia> S, _ = grade(R, [1, 2, 3]) (Graded multivariate polynomial ring in 3 variables over QQ, MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x, y, z]) From 64e3048d6b1194b1970ab7f0d5bf7f4d90b6b67f Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:38:54 +0100 Subject: [PATCH 06/11] adapt doctest to experimenting part 2 --- docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md index f7109041e8d3..53689f4f121c 100644 --- a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md +++ b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md @@ -153,7 +153,7 @@ julia> f = (5*x*y^2-y^10+3)*F[1]+(4*x^3+2*y) *F[2]+16*x*F[3] (5*x*y^2 - y^10 + 3)*e[1] + (4*x^3 + 2*y)*e[2] + 16*x*e[3] julia> default_ordering(F) -degrevlex([x, y])*lex([gen(1), gen(2), gen(3)]) +degrevlex([x, y])*invlex([gen(1), gen(2), gen(3)]) julia> collect(terms(f)) 6-element Vector{FreeModElem{QQMPolyRingElem}}: From c3f29bb8a8dc5ee1034579d259776599f9916565 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:25:41 +0100 Subject: [PATCH 07/11] Fixes minimal_generating_set --- src/Rings/mpolyquo-localizations.jl | 2 +- test/AlgebraicGeometry/Schemes/Tjurina.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index 633652679a38..ecf76f2ac0ce 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -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 diff --git a/test/AlgebraicGeometry/Schemes/Tjurina.jl b/test/AlgebraicGeometry/Schemes/Tjurina.jl index a9014b53b246..ef60b00817d5 100644 --- a/test/AlgebraicGeometry/Schemes/Tjurina.jl +++ b/test/AlgebraicGeometry/Schemes/Tjurina.jl @@ -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] @@ -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 From df45b4c7c44d6899314a5fd924ad79bffac75ed7 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:04:25 +0100 Subject: [PATCH 08/11] Adapted present_finite_extension_ring to conversion fix --- experimental/IntersectionTheory/src/blowup.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/IntersectionTheory/src/blowup.jl b/experimental/IntersectionTheory/src/blowup.jl index d21404c040fc..31733da8ca62 100644 --- a/experimental/IntersectionTheory/src/blowup.jl +++ b/experimental/IntersectionTheory/src/blowup.jl @@ -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 From 6261b37b3ca59ec7b2b170bb5f7f348057cd2423 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:19:48 +0100 Subject: [PATCH 09/11] Revert experimenting (default ordering for modules) --- docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md | 4 ++-- src/Modules/UngradedModules/Methods.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md index 53689f4f121c..382c07afd0fc 100644 --- a/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md +++ b/docs/src/CommutativeAlgebra/GroebnerBases/groebner_bases.md @@ -70,7 +70,7 @@ julia> F = free_module(R, 2) Free module of rank 2 over R julia> default_ordering(F) -degrevlex([x, y, z])*invlex([gen(1), gen(2)]) +degrevlex([x, y, z])*lex([gen(1), gen(2)]) julia> S, _ = grade(R, [1, 2, 3]) (Graded multivariate polynomial ring in 3 variables over QQ, MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}[x, y, z]) @@ -153,7 +153,7 @@ julia> f = (5*x*y^2-y^10+3)*F[1]+(4*x^3+2*y) *F[2]+16*x*F[3] (5*x*y^2 - y^10 + 3)*e[1] + (4*x^3 + 2*y)*e[2] + 16*x*e[3] julia> default_ordering(F) -degrevlex([x, y])*invlex([gen(1), gen(2), gen(3)]) +degrevlex([x, y])*lex([gen(1), gen(2), gen(3)]) julia> collect(terms(f)) 6-element Vector{FreeModElem{QQMPolyRingElem}}: diff --git a/src/Modules/UngradedModules/Methods.jl b/src/Modules/UngradedModules/Methods.jl index 30f06b810f03..822b9036ea85 100644 --- a/src/Modules/UngradedModules/Methods.jl +++ b/src/Modules/UngradedModules/Methods.jl @@ -233,9 +233,9 @@ ring_map(f::SubQuoHom) = f.ring_map function default_ordering(F::FreeMod) if !isdefined(F, :default_ordering) if iszero(F) - F.default_ordering = default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :invlex)) + F.default_ordering = default_ordering(base_ring(F))*ModuleOrdering(F, Orderings.ModOrdering(Vector{Int}(), :lex)) else - F.default_ordering = default_ordering(base_ring(F))*invlex(gens(F)) + F.default_ordering = default_ordering(base_ring(F))*lex(gens(F)) end end return F.default_ordering::ModuleOrdering{typeof(F)} From 4392c1daaf66979e8954cb70cc8bd1464adb3248 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:21:58 +0100 Subject: [PATCH 10/11] Fix ordering conversion for free module over MPolyRing and MPolyDecRing --- src/Rings/mpoly-graded.jl | 5 ++++- src/Rings/mpoly.jl | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Rings/mpoly-graded.jl b/src/Rings/mpoly-graded.jl index 40394f5d9b62..c7f6dd251f08 100644 --- a/src/Rings/mpoly-graded.jl +++ b/src/Rings/mpoly-graded.jl @@ -767,8 +767,11 @@ end end function singular_poly_ring(R::MPolyDecRing; keep_ordering::Bool = false) + @show "richtig verfolgt 1" if !keep_ordering - return singular_poly_ring(forget_decoration(R), default_ordering(R)) + @show "richtig verfolgt 2" + 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 diff --git a/src/Rings/mpoly.jl b/src/Rings/mpoly.jl index ce2543562705..7f91f425d729 100644 --- a/src/Rings/mpoly.jl +++ b/src/Rings/mpoly.jl @@ -617,11 +617,13 @@ 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 @@ -629,7 +631,8 @@ 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 @@ -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 From 26fb5cae0d63e9e6d932d21d4dfae123d31b4f30 Mon Sep 17 00:00:00 2001 From: Syz-MS <125460956+Syz-MS@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:23:19 +0100 Subject: [PATCH 11/11] removed @show --- src/Rings/mpoly-graded.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Rings/mpoly-graded.jl b/src/Rings/mpoly-graded.jl index c7f6dd251f08..8798af5ff31a 100644 --- a/src/Rings/mpoly-graded.jl +++ b/src/Rings/mpoly-graded.jl @@ -767,9 +767,7 @@ end end function singular_poly_ring(R::MPolyDecRing; keep_ordering::Bool = false) - @show "richtig verfolgt 1" if !keep_ordering - @show "richtig verfolgt 2" return singular_poly_ring(forget_decoration(R), singular(default_ordering(R))*Singular.ordering_c()) end