diff --git a/Project.toml b/Project.toml index 77ea19d04c5a..dd8cc471ea6a 100644 --- a/Project.toml +++ b/Project.toml @@ -42,7 +42,7 @@ Random = "1.6" RandomExtensions = "0.4.3" RecipesBase = "1.2.1" Serialization = "1.6" -Singular = "0.19.0" +Singular = "0.20.0" TOPCOM_jll = "0.17.8" UUIDs = "1.6" cohomCalg_jll = "0.32.0" diff --git a/docs/src/CommutativeAlgebra/GroebnerBases/orderings.md b/docs/src/CommutativeAlgebra/GroebnerBases/orderings.md index b612c5c80c15..7fd4a9ec1619 100644 --- a/docs/src/CommutativeAlgebra/GroebnerBases/orderings.md +++ b/docs/src/CommutativeAlgebra/GroebnerBases/orderings.md @@ -153,27 +153,37 @@ lex(R::MPolyRing) The *degree lexicographical ordering* `deglex` is defined by setting $\;\deg(x^\alpha) = \alpha_1 + \cdots + \alpha_n\;$ and -$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) > \deg(x^\beta) \;\text{ or }\; \exists \; 1 \leq i \leq n: \alpha_1 = \beta_1, \dots, \alpha_{i-1} = \beta_{i-1}, \alpha_i > \beta_i.$ +$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) > \deg(x^\beta) \;\text{ or }\; (\deg(x^\alpha) = \deg(x^\beta) \;\text{ and }\; \exists \; 1 \leq i \leq n: \alpha_1 = \beta_1, \dots, \alpha_{i-1} = \beta_{i-1}, \alpha_i > \beta_i).$ ```@docs deglex(R::MPolyRing) ``` -#### The Reverse Lexicographical Ordering +#### The Inverse Lexicographical Ordering -The *reverse lexicographical ordering* `revlex` is defined by setting +The *inverse lexicographical ordering* `invlex` is defined by setting $x^\alpha > x^\beta \; \Leftrightarrow \;\exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i > \beta_i.$ ```@docs -revlex(R::MPolyRing) +invlex(R::MPolyRing) +``` + +#### The Degree Inverse Lexicographical Ordering + +The *degree inverse lexicographical ordering* `deginvlex` is defined by setting + +$x^\alpha > x^\beta \; \Leftrightarrow \deg(x^\alpha) > \deg(x^\beta) \;\text{ or }\;(\deg(x^\alpha) = \deg(x^\beta) \;\text{ and }\; \;\exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i > \beta_i).$ + +```@docs +deginvlex(R::MPolyRing) ``` #### The Degree Reverse Lexicographical Ordering The *degree reverse lexicographical ordering* `degrevlex` is defined by setting $\;\deg(x^\alpha) = \alpha_1 + \cdots + \alpha_n\;$ and -$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) > \deg(x^\beta) \;\text{ or }\;\exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i < \beta_i.$ +$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) > \deg(x^\beta) \;\text{ or }\;(\deg(x^\alpha) = \deg(x^\beta) \;\text{ and }\; \exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i < \beta_i).$ ```@docs degrevlex(R::MPolyRing) @@ -219,27 +229,27 @@ neglex(R::MPolyRing) The *negative degree lexicographical ordering* `negdeglex` is defined by setting $\;\deg(x^\alpha) = \alpha_1 + \cdots + \alpha_n\;$ and -$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) < \deg(x^\beta) \;\text{ or }\; \exists \; 1 \leq i \leq n: \alpha_1 = \beta_1, \dots, \alpha_{i-1} = \beta_{i-1}, \alpha_i > \beta_i.$ +$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) < \deg(x^\beta) \;\text{ or }\; (\deg(x^\alpha) = \deg(x^\beta) \;\text{ and }\; \exists \; 1 \leq i \leq n: \alpha_1 = \beta_1, \dots, \alpha_{i-1} = \beta_{i-1}, \alpha_i > \beta_i).$ ```@docs negdeglex(R::MPolyRing) ``` -#### The Negative Reverse Lexicographical Ordering +#### The Negative Inverse Lexicographical Ordering -The *negative reverse lexicographical ordering* `negrevlex` is defined by setting +The *negative inverse lexicographical ordering* `neginvlex` is defined by setting $x^\alpha > x^\beta \; \Leftrightarrow \;\exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i < \beta_i.$ ```@docs -negrevlex(R::MPolyRing) +neginvlex(R::MPolyRing) ``` #### The Negative Degree Reverse Lexicographical Ordering The *negative degree reverse lexicographical ordering* `negdegrevlex` is defined by setting $\;\deg(x^\alpha) = \alpha_1 + \cdots + \alpha_n\;$ and -$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) < \deg(x^\beta) \;\text{ or }\;\exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i < \beta_i.$ +$x^\alpha > x^\beta \; \Leftrightarrow \; \deg(x^\alpha) < \deg(x^\beta) \;\text{ or }\;(\deg(x^\alpha) = \deg(x^\beta) \;\text{ and }\; \exists \; 1 \leq i \leq n: \alpha_n = \beta_n, \dots, \alpha_{i+1} = \beta_{i+1}, \alpha_i < \beta_i).$ ```@docs negdegrevlex(R::MPolyRing) @@ -392,7 +402,7 @@ Alternatively, we may wish to use $i < j$ instead of $i > j$ in this definition. In other words, these orderings are obtained by concatenating a monomial ordering on the monomials of $R$ with a way of ordering the basis vectors of $F$ or vice versa. In OSCAR, we refer to the $i < j$ ordering on the -basis vectors as *lex*, and to the $i > j$ ordering as *revlex*. And, we use the `*` operator for concatenation. +basis vectors as *lex*, and to the $i > j$ ordering as *invlex*. And, we use the `*` operator for concatenation. ##### Examples @@ -402,11 +412,11 @@ julia> R, (w, x, y, z) = polynomial_ring(QQ, ["w", "x", "y", "z"]); julia> F = free_module(R, 3) Free module of rank 3 over Multivariate polynomial ring in 4 variables over QQ -julia> o1 = degrevlex(R)*revlex(gens(F)) -degrevlex([w, x, y, z])*revlex([gen(1), gen(2), gen(3)]) +julia> o1 = degrevlex(R)*invlex(gens(F)) +degrevlex([w, x, y, z])*invlex([gen(1), gen(2), gen(3)]) -julia> o2 = revlex(gens(F))*degrevlex(R) -revlex([gen(1), gen(2), gen(3)])*degrevlex([w, x, y, z]) +julia> o2 = invlex(gens(F))*degrevlex(R) +invlex([gen(1), gen(2), gen(3)])*degrevlex([w, x, y, z]) ``` diff --git a/experimental/BasisLieHighestWeight/test/MainAlgorithm-test.jl b/experimental/BasisLieHighestWeight/test/MainAlgorithm-test.jl index a3a8959bb35a..6cac1c4c5623 100644 --- a/experimental/BasisLieHighestWeight/test/MainAlgorithm-test.jl +++ b/experimental/BasisLieHighestWeight/test/MainAlgorithm-test.jl @@ -553,7 +553,7 @@ end @testset "Check dimension" begin @testset "Monomial order $monomial_ordering" for monomial_ordering in - (:lex, :revlex, :degrevlex) + (:lex, :invlex, :degrevlex) check_dimension(:A, 3, [1, 1, 1], monomial_ordering) #check_dimension(:B, 3, [2,1,0], monomial_ordering) #check_dimension(:C, 3, [1,1,1], monomial_ordering) diff --git a/src/Modules/FreeModElem-orderings.jl b/src/Modules/FreeModElem-orderings.jl index 550797227aa6..89146348ca7d 100644 --- a/src/Modules/FreeModElem-orderings.jl +++ b/src/Modules/FreeModElem-orderings.jl @@ -6,8 +6,8 @@ function Orderings.lex(F::ModuleFP) return Orderings.ModuleOrdering(F, Orderings.ModOrdering(1:ngens(F), :lex)) end -function Orderings.revlex(F::ModuleFP) - return Orderings.ModuleOrdering(F, Orderings.ModOrdering(1:ngens(F), :revlex)) +function Orderings.invlex(F::ModuleFP) + return Orderings.ModuleOrdering(F, Orderings.ModOrdering(1:ngens(F), :invlex)) end @doc raw""" diff --git a/src/Rings/mpoly-graded.jl b/src/Rings/mpoly-graded.jl index f9eb4ae15617..c982a83e89bc 100644 --- a/src/Rings/mpoly-graded.jl +++ b/src/Rings/mpoly-graded.jl @@ -1912,7 +1912,7 @@ function homogenization(I::MPolyIdeal{T}, W::Union{ZZMatrix, Matrix{<:IntegerUni N = ngens(Ph) num_x = ngens(P) num_h = ngens(Ph) - num_x - # Build ordering matrix: weights matrix followed by identity mat, underneath is a revlex matrix + # Build ordering matrix: weights matrix followed by identity mat, underneath is a invlex matrix Id = reduce(hcat, [[kronecker_delta(i,j) for i in 1:num_h] for j in 1:num_h]) RevLexMat = reduce(hcat, [[-kronecker_delta(i+j, 1+ngens(Ph)) for i in 1:ngens(Ph)] for j in 1:ngens(Ph)]) M = hcat(W, Id) diff --git a/src/Rings/mpolyquo-localizations.jl b/src/Rings/mpolyquo-localizations.jl index c02e688342d9..9735d8f78aea 100644 --- a/src/Rings/mpolyquo-localizations.jl +++ b/src/Rings/mpolyquo-localizations.jl @@ -2197,7 +2197,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)*revlex(F) + oF = negdegrevlex(R)*invlex(F) res_vec = typeof(gen(I,1))[] ## select by Nakayama diff --git a/src/Rings/orderings.jl b/src/Rings/orderings.jl index 499395da5419..2a627f5e0208 100644 --- a/src/Rings/orderings.jl +++ b/src/Rings/orderings.jl @@ -13,6 +13,8 @@ export degrevlex export index_of_leading_term export induce export induced_ring_ordering +export deginvlex +export invlex export is_elimination_ordering export is_global export is_local @@ -24,13 +26,12 @@ export matrix_ordering export monomial_ordering export negdeglex export negdegrevlex +export neginvlex export neglex -export negrevlex export negwdeglex export negwdegrevlex export opposite_ordering export permutation_of_terms -export revlex export singular export wdeglex export wdegrevlex @@ -46,8 +47,8 @@ abstract type AbsModOrdering <: AbsOrdering end struct SymbOrdering{S} <: AbsGenOrdering vars::Vector{Int} function SymbOrdering(S::Symbol, v) - S in (:lex, :deglex, :degrevlex, :revlex, - :neglex, :negdeglex, :negdegrevlex, :negrevlex) || + S in (:lex, :deglex, :degrevlex, :invlex, :revlex, :deginvlex, + :neglex, :negdeglex, :negdegrevlex, :neginvlex, :negrevlex) || throw(ArgumentError("unsupported ordering $S")) return new{S}(v) end @@ -217,8 +218,8 @@ end monomial_ordering(v::AbstractVector{<:MPolyRingElem}, s::Symbol) Defines an ordering to be applied to the variables in `v`. The symbol `s` -should be one of `:lex`, `:deglex`, `:degrevlex`, `:revlex`, `:neglex`, -`:negdeglex`, `:negdegrevlex`, `:negrevlex`. +should be one of `:lex`, `:deglex`, `:degrevlex`, `:invlex`, `:deginvlex`, `:neglex`, +`:negdeglex`, `:negdegrevlex`, `:neginvlex`. """ function monomial_ordering(v::AbstractVector{<:MPolyRingElem}, s::Symbol) i = _unique_var_indices(v) @@ -437,24 +438,24 @@ function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::S return 0 end -#### revlex #### +#### invlex #### @doc raw""" - revlex(R::MPolyRing) -> MonomialOrdering + invlex(R::MPolyRing) -> MonomialOrdering -Return the reverse lexicographical ordering on the set of monomials in the variables of `R`. +Return the inverse lexicographical ordering on the set of monomials in the variables of `R`. - revlex(V::AbstractVector{<:MPolyRingElem}) -> MonomialOrdering + invlex(V::AbstractVector{<:MPolyRingElem}) -> MonomialOrdering -Given a vector `V` of variables, return the reverse lexicographical ordering on the set of monomials in these variables. +Given a vector `V` of variables, return the inverse lexicographical ordering on the set of monomials in these variables. # Examples ```jldoctest julia> R, (w, x, y, z) = polynomial_ring(QQ, ["w", "x", "y", "z"]) (Multivariate polynomial ring in 4 variables over QQ, QQMPolyRingElem[w, x, y, z]) -julia> o1 = revlex(R) -revlex([w, x, y, z]) +julia> o1 = invlex(R) +invlex([w, x, y, z]) julia> canonical_matrix(o1) [0 0 0 1] @@ -462,23 +463,24 @@ julia> canonical_matrix(o1) [0 1 0 0] [1 0 0 0] -julia> o2 = revlex([w, x]) -revlex([w, x]) +julia> o2 = invlex([w, x]) +invlex([w, x]) -julia> o3 = revlex(gens(R)[3:4]) -revlex([y, z]) +julia> o3 = invlex(gens(R)[3:4]) +invlex([y, z]) ``` """ -function revlex(R::MPolyRing) - return MonomialOrdering(R, SymbOrdering(:revlex, 1:nvars(R))) +function invlex(R::MPolyRing) + return MonomialOrdering(R, SymbOrdering(:invlex, 1:nvars(R))) end -function revlex(v::AbstractVector{<:MPolyRingElem}) +function invlex(v::AbstractVector{<:MPolyRingElem}) i = _unique_var_indices(v) - return MonomialOrdering(parent(first(v)), SymbOrdering(:revlex, i)) + return MonomialOrdering(parent(first(v)), SymbOrdering(:invlex, i)) end -function _matrix(nvars::Int, o::SymbOrdering{:revlex}) + +function _matrix(nvars::Int, o::SymbOrdering{:invlex}) m = zero_matrix(ZZ, length(o.vars), nvars) i = length(o.vars) for j in o.vars @@ -488,7 +490,81 @@ function _matrix(nvars::Int, o::SymbOrdering{:revlex}) return m end -function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::SymbOrdering{:revlex}) +function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::SymbOrdering{:invlex}) + for i in reverse(o.vars) + ek = exponent(f, k, i) + el = exponent(g, l, i) + if ek > el + return 1 + elseif ek < el + return -1 + end + end + return 0 +end + +#### deginvlex #### + +@doc raw""" + deginvlex(R::MPolyRing) -> MonomialOrdering + +Return the degree inverse lexicographical ordering on the set of monomials in the variables of `R`. + + deginvlex(V::AbstractVector{<:MPolyRingElem}) -> MonomialOrdering + +Given a vector `V` of variables, return the degree inverse lexicographical ordering on the set of monomials in these variables. + +# Examples +```jldoctest +julia> R, (w, x, y, z) = polynomial_ring(QQ, ["w", "x", "y", "z"]) +(Multivariate polynomial ring in 4 variables over QQ, QQMPolyRingElem[w, x, y, z]) + +julia> o1 = deginvlex(R) +deginvlex([w, x, y, z]) + +julia> canonical_matrix(o1) +[1 1 1 1] +[0 0 0 1] +[0 0 1 0] +[0 1 0 0] + +julia> o2 = deginvlex([w, x]) +deginvlex([w, x]) + +julia> o3 = deginvlex(gens(R)[3:4]) +deginvlex([y, z]) +``` +""" +function deginvlex(R::MPolyRing) + return MonomialOrdering(R, SymbOrdering(:deginvlex, 1:nvars(R))) +end + +function deginvlex(v::AbstractVector{<:MPolyRingElem}) + i = _unique_var_indices(v) + return MonomialOrdering(parent(first(v)), SymbOrdering(:deginvlex, i)) +end + +function _matrix(nvars::Int, o::SymbOrdering{:deginvlex}) + m = zero_matrix(ZZ, 1 + length(o.vars), nvars) + for j in o.vars + m[1, j] = 1 + end + i = 1 + length(o.vars) + for j in o.vars + m[i, j] = 1 + i -= 1 + end + return m +end + +function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::SymbOrdering{:deginvlex}) + tdk = sum(exponent(f, k, i) for i in o.vars) + tdl = sum(exponent(g, l, i) for i in o.vars) + if tdk > tdl + return 1 + elseif tdk < tdl + return -1 + end for i in reverse(o.vars) ek = exponent(f, k, i) el = exponent(g, l, i) @@ -565,24 +641,24 @@ function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::S return 0 end -#### negrevlex #### +#### neginvlex #### @doc raw""" - negrevlex(R::MPolyRing) -> MonomialOrdering + neginvlex(R::MPolyRing) -> MonomialOrdering -Return the negative reverse lexicographical ordering on the set of monomials in the variables of `R`. +Return the negative inverse lexicographical ordering on the set of monomials in the variables of `R`. - negrevlex(V::AbstractVector{<:MPolyRingElem}) -> MonomialOrdering + neginvlex(V::AbstractVector{<:MPolyRingElem}) -> MonomialOrdering -Given a vector `V` of variables, return the negative reverse lexicographical ordering on the set of monomials in these variables. +Given a vector `V` of variables, return the negative inverse lexicographical ordering on the set of monomials in these variables. # Examples ```jldoctest julia> R, (w, x, y, z) = polynomial_ring(QQ, ["w", "x", "y", "z"]) (Multivariate polynomial ring in 4 variables over QQ, QQMPolyRingElem[w, x, y, z]) -julia> o1 = negrevlex(R) -negrevlex([w, x, y, z]) +julia> o1 = neginvlex(R) +neginvlex([w, x, y, z]) julia> canonical_matrix(o1) [ 0 0 0 -1] @@ -590,23 +666,23 @@ julia> canonical_matrix(o1) [ 0 -1 0 0] [-1 0 0 0] -julia> o2 = negrevlex([w, x]) -negrevlex([w, x]) +julia> o2 = neginvlex([w, x]) +neginvlex([w, x]) -julia> o3 = negrevlex(gens(R)[3:4]) -negrevlex([y, z]) +julia> o3 = neginvlex(gens(R)[3:4]) +neginvlex([y, z]) ``` """ -function negrevlex(R::MPolyRing) - return MonomialOrdering(R, SymbOrdering(:negrevlex, 1:nvars(R))) +function neginvlex(R::MPolyRing) + return MonomialOrdering(R, SymbOrdering(:neginvlex, 1:nvars(R))) end -function negrevlex(v::AbstractVector{<:MPolyRingElem}) +function neginvlex(v::AbstractVector{<:MPolyRingElem}) i = _unique_var_indices(v) - return MonomialOrdering(parent(first(v)), SymbOrdering(:negrevlex, i)) + return MonomialOrdering(parent(first(v)), SymbOrdering(:neginvlex, i)) end -function _matrix(nvars::Int, o::SymbOrdering{:negrevlex}) +function _matrix(nvars::Int, o::SymbOrdering{:neginvlex}) m = zero_matrix(ZZ, length(o.vars), nvars) i = length(o.vars) for j in o.vars @@ -616,7 +692,7 @@ function _matrix(nvars::Int, o::SymbOrdering{:negrevlex}) return m end -function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::SymbOrdering{:negrevlex}) +function _cmp_monomials(f::MPolyRingElem, k::Int, g::MPolyRingElem, l::Int, o::SymbOrdering{:neginvlex}) for i in reverse(o.vars) ek = exponent(f, k, i) el = exponent(g, l, i) @@ -1467,7 +1543,7 @@ julia> cmp(lex([x,y,z]), z, one(R)) julia> F = free_module(R, 2) Free module of rank 2 over Multivariate polynomial ring in 3 variables over QQ -julia> cmp(lex(R)*revlex(F), F[1], F[2]) +julia> cmp(lex(R)*invlex(F), F[1], F[2]) -1 ``` """ @@ -1677,7 +1753,7 @@ function _cmp_vector_monomials( if o.ord == :lex return m < n ? 1 : m > n ? -1 : 0 - elseif o.ord == :revlex + elseif o.ord == :invlex return m > n ? 1 : m < n ? -1 : 0 else error("oops") @@ -1726,8 +1802,8 @@ function lex(v::AbstractVector{<:AbstractAlgebra.ModuleElem}) return ModuleOrdering(parent(first(v)), ordering(v, :lex)) end -function revlex(v::AbstractVector{<:AbstractAlgebra.ModuleElem}) - return ModuleOrdering(parent(first(v)), ordering(v, :revlex)) +function invlex(v::AbstractVector{<:AbstractAlgebra.ModuleElem}) + return ModuleOrdering(parent(first(v)), ordering(v, :invlex)) end function Base.:*(M::ModuleOrdering, N::MonomialOrdering) @@ -1752,8 +1828,8 @@ julia> R, (w, x, y, z) = polynomial_ring(QQ, ["w", "x", "y", "z"]); julia> F = free_module(R, 3) Free module of rank 3 over Multivariate polynomial ring in 4 variables over QQ -julia> o = revlex(gens(F))*degrevlex(R) -revlex([gen(1), gen(2), gen(3)])*degrevlex([w, x, y, z]) +julia> o = invlex(gens(F))*degrevlex(R) +invlex([gen(1), gen(2), gen(3)])*degrevlex([w, x, y, z]) julia> induced_ring_ordering(o) degrevlex([w, x, y, z]) @@ -1868,7 +1944,7 @@ function _opposite_ordering(nvars::Int, o::SymbOrdering{:deglex}) n = length(o.vars) newvars = reverse(nvars+1 .- o.vars) return MatrixOrdering(newvars, ZZMatrix(1, n, ones(Int, n)), false)* - SymbOrdering(:revlex, newvars) + SymbOrdering(:invlex, newvars) end # TODO ditto @@ -1922,10 +1998,13 @@ function _try_singular_easy(Q::order_conversion_ctx, o::SymbOrdering{S}) where S Q.last_var += n return S == :lex ? (true, Singular.ordering_lp(n)) : S == :revlex ? (true, Singular.ordering_rp(n)) : + S == :invlex ? (true, Singular.ordering_ip(n)) : + S == :deginvlex ? (true, Singular.ordering_Ip(n)) : S == :deglex ? (true, Singular.ordering_Dp(n)) : S == :degrevlex ? (true, Singular.ordering_dp(n)) : + S == :deginvlex ? (true, Singular.ordering_Ip(n)) : S == :neglex ? (true, Singular.ordering_ls(n)) : - S == :negrevlex ? (true, Singular.ordering_rs(n)) : + S == :neginvlex ? (true, Singular.ordering_is(n)) : S == :negdeglex ? (true, Singular.ordering_Ds(n)) : S == :negdegrevlex ? (true, Singular.ordering_ds(n)) : (false, Q.def) @@ -1959,7 +2038,7 @@ function _try_singular_easy(Q::order_conversion_ctx, o::Orderings.ModOrdering) 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 == :revlex ? (true, Singular.ordering_c(length(o.gens))) : + o.ord == :invlex ? (true, Singular.ordering_c(length(o.gens))) : (false, Q.def) end @@ -2001,16 +2080,18 @@ function _convert_sblock(nvars::Int, o::Singular.sorder_block, lastvar::Int) i = collect(lastvar+1:newlastvar) if o.order == Singular.ringorder_lp return SymbOrdering(:lex, i), newlastvar - elseif o.order == Singular.ringorder_rp - return SymbOrdering(:revlex, i), newlastvar + elseif o.order == Singular.ringorder_ip + return SymbOrdering(:invlex, i), newlastvar elseif o.order == Singular.ringorder_Dp return SymbOrdering(:deglex, i), newlastvar + elseif o.order == Singular.ringorder_Ip + return SymbOrdering(:deginvlex, i), newlastvar elseif o.order == Singular.ringorder_dp return SymbOrdering(:degrevlex, i), newlastvar elseif o.order == Singular.ringorder_ls return SymbOrdering(:neglex, i), newlastvar - elseif o.order == Singular.ringorder_rs - return SymbOrdering(:negrevlex, i), newlastvar + elseif o.order == Singular.ringorder_is + return SymbOrdering(:neginvlex, i), newlastvar elseif o.order == Singular.ringorder_Ds return SymbOrdering(:negdeglex, i), newlastvar elseif o.order == Singular.ringorder_ds diff --git a/src/TropicalGeometry/groebner_fan.jl b/src/TropicalGeometry/groebner_fan.jl index 0a54f22f96b2..5ad06b22defd 100644 --- a/src/TropicalGeometry/groebner_fan.jl +++ b/src/TropicalGeometry/groebner_fan.jl @@ -349,7 +349,7 @@ function groebner_flip_adjacent_ordering(R::MPolyRing, return weight_ordering(Int.(homogeneityVector), weight_ordering(Int.(interior_facet_point), weight_ordering(Int.(outer_normal_vector), - revlex(R)))) + invlex(R)))) end function groebner_flip_adjacent_ordering(R::MPolyRing, @@ -358,7 +358,7 @@ function groebner_flip_adjacent_ordering(R::MPolyRing, outer_normal_vector::Vector{ZZRingElem}) return weight_ordering(Int.(interior_facet_point), weight_ordering(Int.(outer_normal_vector), - revlex(R))) + invlex(R))) end @@ -424,7 +424,7 @@ julia> SigmaI,gbs,ords = groebner_fan(I,return_groebner_bases=true,return_orderi 3-element Vector{Any}: Polyhedral fan in ambient dimension 3 Dict{Vector{ZZRingElem}, Vector{QQMPolyRingElem}}([0, -1, 0] => [x1, x2 + x3], [0, 0, -1] => [x2 + x3, x1]) - Dict{Vector{ZZRingElem}, MonomialOrdering{QQMPolyRing}}([0, -1, 0] => matrix_ordering([x1, x2, x3], [1 1 1])*matrix_ordering([x1, x2, x3], [0 0 0])*matrix_ordering([x1, x2, x3], [0 -1 1])*revlex([x1, x2, x3]), [0, 0, -1] => degrevlex([x1, x2, x3])) + Dict{Vector{ZZRingElem}, MonomialOrdering{QQMPolyRing}}([0, -1, 0] => matrix_ordering([x1, x2, x3], [1 1 1])*matrix_ordering([x1, x2, x3], [0 0 0])*matrix_ordering([x1, x2, x3], [0 -1 1])*invlex([x1, x2, x3]), [0, 0, -1] => degrevlex([x1, x2, x3])) ``` """ diff --git a/src/deprecations.jl b/src/deprecations.jl index 04763a68f1a1..d9c83ef61995 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -488,3 +488,9 @@ function blow_up(v::NormalToricVarietyType, I::MPolyIdeal, coordinate_name::Stri Base.depwarn("The keyword argument set_attributes is deprecated. Please use the function without the keyword.", :blow_up) return blow_up(v, I, coordinate_name) end + +# Deprecated after 0.14.0 +@deprecate revlex(R::MPolyRing) invlex(R::MPolyRing) +@deprecate revlex(v::AbstractVector{<:MPolyRingElem}) invlex(v::AbstractVector{<:MPolyRingElem}) +@deprecate negrevlex(R::MPolyRing) ngeinvlex(R::MPolyRing) +@deprecate negrevlex(v::AbstractVector{<:MPolyRingElem}) neginvlex(v::AbstractVector{<:MPolyRingElem}) diff --git a/src/exports.jl b/src/exports.jl index dbd6c34c60aa..1c0bf225a469 100644 --- a/src/exports.jl +++ b/src/exports.jl @@ -443,6 +443,7 @@ export defining_equation export defining_ideal export defining_ring_element export defining_ring_elements +export deginvlex export deglex export degree export degrees_of_generators @@ -737,6 +738,7 @@ export inverse export invert export invert_birational_map export inverted_set +export invlex export irreducible_components export irreducible_secondary_invariants export irreducibles @@ -1064,8 +1066,8 @@ export nef_cone export negbias export negdeglex export negdegrevlex +export neginvlex export neglex -export negrevlex export negwdeglex export negwdegrevlex export neighbor_patches @@ -1304,7 +1306,6 @@ export restriction_map export restrictions export reverse export reverse_direction! -export revlex export revlex_basis_encoding export reynolds_operator export right_acting_group diff --git a/test/Modules/FreeModElem-orderings.jl b/test/Modules/FreeModElem-orderings.jl index 6c3fd78f2b4a..9e4152fc38e3 100644 --- a/test/Modules/FreeModElem-orderings.jl +++ b/test/Modules/FreeModElem-orderings.jl @@ -41,10 +41,10 @@ t = tail(a) @test a == leading_term(a) + t - @test collect(terms(a; ordering = lex([w,x])*revlex(F)*lex([y,z]))) == + @test collect(terms(a; ordering = lex([w,x])*invlex(F)*lex([y,z]))) == [2*w*F[2], 2*w*F[1], 3*x*F[2], 3*x*F[1], 4*y*F[2], 5*z*F[2], F[2], 4*y*F[1], 5*z*F[1], F[1]] - @test_throws ErrorException induced_ring_ordering(revlex(F)) - @test induced_ring_ordering(lex([w,x])*revlex(F)*lex([y,z])) == lex([w,x,y,z]) + @test_throws ErrorException induced_ring_ordering(invlex(F)) + @test induced_ring_ordering(lex([w,x])*invlex(F)*lex([y,z])) == lex([w,x,y,z]) end diff --git a/test/Rings/MPolyQuo.jl b/test/Rings/MPolyQuo.jl index c8a43cda326a..8e384bd858fb 100644 --- a/test/Rings/MPolyQuo.jl +++ b/test/Rings/MPolyQuo.jl @@ -263,7 +263,7 @@ end @testset "divides hack" begin R, (x, y) = QQ["x", "y"] I = ideal(R, 1-x*y) - o = revlex([x, y]) + o = invlex([x, y]) Q = MPolyQuoRing(R, I, o) @test Oscar._divides_hack(one(Q), Q(y))[2] == Q(x) end diff --git a/test/Rings/PBWAlgebra.jl b/test/Rings/PBWAlgebra.jl index d6fadb89f073..298bc07d0d8e 100644 --- a/test/Rings/PBWAlgebra.jl +++ b/test/Rings/PBWAlgebra.jl @@ -179,7 +179,7 @@ end r, (a, h, f, e) = QQ["a", "h", "f", "e"] rel = @pbw_relations(e*f == f*e-h, e*h == h*e+2*e, f*h == h*f-2*f) - for o in [revlex(r), deglex(r)] + for o in [invlex(r), deglex(r)] R, (a, h, f, e) = pbw_algebra(r, rel, o) I = right_ideal([e^3, f^3, h^3-4*h, 4*f*e+h^2-2*h-a]) @test eliminate(I, [e, f, h]) == right_ideal([a^3 - 32*a^2 + 192*a]) diff --git a/test/Rings/PBWAlgebraQuo.jl b/test/Rings/PBWAlgebraQuo.jl index f23e95541f1a..07eccd5d3167 100644 --- a/test/Rings/PBWAlgebraQuo.jl +++ b/test/Rings/PBWAlgebraQuo.jl @@ -33,7 +33,7 @@ end @testset "PBWAlgebraQuo.conformance" begin r, (a, h, f, e) = QQ["a", "h", "f", "e"] rel = @pbw_relations(e*f == f*e-h, e*h == h*e+2*e, f*h == h*f-2*f) - R, (a, h, f, e) = pbw_algebra(r, rel, revlex(r)) + R, (a, h, f, e) = pbw_algebra(r, rel, invlex(r)) Q, _ = quo(R, two_sided_ideal(R, [h])) test_NCRing_interface(Q; reps = 1) end diff --git a/test/Rings/groebner.jl b/test/Rings/groebner.jl index 29a648763491..3a0fa3760f2b 100644 --- a/test/Rings/groebner.jl +++ b/test/Rings/groebner.jl @@ -77,7 +77,7 @@ end @test leading_ideal(groebner_basis(I, ordering=lex([t, x, y, z]))) == ideal(R, [x^3, t]) @test leading_ideal(groebner_basis(I, ordering=degrevlex([t, x, y, z]))) == ideal(R, [t, x^3]) @test leading_ideal(groebner_basis(I, ordering=lex([t, x, y, z]))) == ideal(R, [x^3, t]) - @test leading_ideal(groebner_basis(I, ordering=revlex([t, x, y, z]))) == ideal(R, [y^2, z]) + @test leading_ideal(groebner_basis(I, ordering=invlex([t, x, y, z]))) == ideal(R, [y^2, z]) @test leading_ideal(groebner_basis(I, ordering=wdeglex([t, x, y, z], [2, 3, 1, 4]))) == ideal(R, [z, t^3]) @test leading_ideal(groebner_basis(I, ordering=wdegrevlex([t, x, y, z], [2, 1, 1, 1]))) == ideal(R, [t, x^3]) end @@ -88,8 +88,8 @@ end I = ideal(R, [x + y + z, x^2 + y^2 + z^3]) @test groebner_basis(I, ordering=lex([x])*lex([y,z])) == groebner_basis(I, ordering=lex([x, y, z])) - @test groebner_basis(I, ordering=lex([z])*lex([y])*lex([x])) == groebner_basis(I, ordering=revlex([x, y, z])) - @test groebner_basis(I, ordering=degrevlex([x, y, z])*revlex([y])) == groebner_basis(I, ordering=degrevlex([x, y, z])) + @test groebner_basis(I, ordering=lex([z])*lex([y])*lex([x])) == groebner_basis(I, ordering=invlex([x, y, z])) + @test groebner_basis(I, ordering=degrevlex([x, y, z])*invlex([y])) == groebner_basis(I, ordering=degrevlex([x, y, z])) @test groebner_basis(I, ordering=deglex([z])*deglex([x])*deglex([y])) == groebner_basis(I, ordering=lex([z])*lex([x, y])) @test groebner_basis(I, ordering=deglex([x, y, z])) == groebner_basis(I, ordering=wdeglex([x, y, z], [1, 1, 1])) M = matrix_ordering([x, y, z], [1 1 1; 0 1 0; 1 0 0]) @@ -101,9 +101,9 @@ end H, V = groebner_basis_with_transformation_matrix(I, ordering=lex([x, y, z])) @test gens(G) == gens(H) && U == V G, U = groebner_basis_with_transformation_matrix(I, ordering=lex([z])*lex([y])*lex([x])) - H, V = groebner_basis_with_transformation_matrix(I, ordering=revlex([x, y, z])) + H, V = groebner_basis_with_transformation_matrix(I, ordering=invlex([x, y, z])) @test gens(G) == gens(H) && U == V - G, U = groebner_basis_with_transformation_matrix(I, ordering=degrevlex([x, y, z])*revlex([y])) + G, U = groebner_basis_with_transformation_matrix(I, ordering=degrevlex([x, y, z])*invlex([y])) H, V = groebner_basis_with_transformation_matrix(I, ordering=degrevlex([x, y, z])) @test gens(G) == gens(H) && U == V G, U = groebner_basis_with_transformation_matrix(I, ordering=deglex([z])*deglex([x])*deglex([y])) diff --git a/test/Rings/orderings.jl b/test/Rings/orderings.jl index 93353a5d6fb9..10b25b0d7631 100644 --- a/test/Rings/orderings.jl +++ b/test/Rings/orderings.jl @@ -4,11 +4,12 @@ g = (1 + x + y + z)^2 @test isa(lex([x, y]), MonomialOrdering) - @test isa(revlex([x, y, z]), MonomialOrdering) + @test isa(invlex([x, y, z]), MonomialOrdering) + @test isa(deginvlex([x, y, z]), MonomialOrdering) @test isa(degrevlex([x, z]), MonomialOrdering) @test isa(deglex([x, y, z]), MonomialOrdering) @test isa(neglex([x, y, z]), MonomialOrdering) - @test isa(negrevlex([x, y, z]), MonomialOrdering) + @test isa(neginvlex([x, y, z]), MonomialOrdering) @test isa(negdeglex([x, y, z]), MonomialOrdering) @test isa(negdegrevlex([x, y, z]), MonomialOrdering) @test isa(matrix_ordering([x, y, z], matrix(ZZ, [1 1 1; 1 0 0; 0 1 0])), MonomialOrdering) @@ -18,23 +19,24 @@ @test isa(negwdeglex([x, y], [1, 2]), MonomialOrdering) @test isa(negwdegrevlex([x, y], [1, 2]), MonomialOrdering) - @test isa(revlex([x, y])*neglex([z]), MonomialOrdering) + @test isa(invlex([x, y])*neglex([z]), MonomialOrdering) @test collect(monomials(g; ordering = lex(R))) == [x^2, x*y, x*z, x, y^2, y*z, y, z^2, z, 1] # lp - @test collect(monomials(g; ordering = revlex(R))) == [z^2, y*z, x*z, z, y^2, x*y, y, x^2, x, 1] # rp + @test collect(monomials(g; ordering = invlex(R))) == [z^2, y*z, x*z, z, y^2, x*y, y, x^2, x, 1] # ip + @test collect(monomials(g; ordering = deginvlex(R))) == [z^2, y*z, x*z, y^2, x*y, x^2, z, y, x, 1] # Ip @test collect(monomials(g; ordering = deglex(R))) == [x^2, x*y, x*z, y^2, y*z, z^2, x, y, z, 1] # Dp @test collect(monomials(g; ordering = degrevlex(R))) == [x^2, x*y, y^2, x*z, y*z, z^2, x, y, z, 1] # dp @test collect(monomials(g; ordering = neglex(R))) == [1, z, z^2, y, y*z, y^2, x, x*z, x*y, x^2] # ls - @test collect(monomials(g; ordering = negrevlex(R))) == [1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2] # rs not documented ? + @test collect(monomials(g; ordering = neginvlex(R))) == [1, x, x^2, y, x*y, y^2, z, x*z, y*z, z^2] # rs not documented ? @test collect(monomials(g; ordering = negdeglex(R))) == [1, x, y, z, x^2, x*y, x*z, y^2, y*z, z^2] # Ds @test collect(monomials(g; ordering = negdegrevlex(R))) == [1, x, y, z, x^2, x*y, y^2, x*z, y*z, z^2] # ds @test collect(monomials(f; ordering = lex(R))) == [ x*y, z^3 ] - @test collect(monomials(f; ordering = revlex(R))) == [ z^3, x*y ] + @test collect(monomials(f; ordering = invlex(R))) == [ z^3, x*y ] @test collect(monomials(f; ordering = deglex(R))) == [ z^3, x*y ] @test collect(monomials(f; ordering = degrevlex(R))) == [ z^3, x*y ] @test collect(monomials(f; ordering = neglex(R))) == [ z^3, x*y ] - @test collect(monomials(f; ordering = negrevlex(R))) == [ x*y, z^3 ] + @test collect(monomials(f; ordering = neginvlex(R))) == [ x*y, z^3 ] @test collect(monomials(f; ordering = negdeglex(R))) == [ x*y, z^3 ] @test collect(monomials(f; ordering = negdegrevlex(R))) == [ x*y, z^3 ] @@ -94,9 +96,10 @@ @test lex(R) == lex(gens(R)) @test deglex(R) == deglex(gens(R)) @test degrevlex(R) == degrevlex(gens(R)) - @test revlex(R) == revlex(gens(R)) + @test invlex(R) == invlex(gens(R)) + @test deginvlex(R) == deginvlex(gens(R)) @test neglex(R) == neglex(gens(R)) - @test negrevlex(R) == negrevlex(gens(R)) + @test neginvlex(R) == neginvlex(gens(R)) @test negdegrevlex(R) == negdegrevlex(gens(R)) @test negdeglex(R) == negdeglex(gens(R)) @test wdeglex(R, [1,2,3]) == wdeglex(gens(R), [1,2,3]) @@ -115,13 +118,13 @@ end a = lex([x, t])*deglex([y, z]) @test is_total(a) && is_total(a) - a = degrevlex([x, z, t])*revlex([y, t]) + a = degrevlex([x, z, t])*invlex([y, t]) @test is_total(a) && is_total(a) a = neglex([y, z, t]) @test !is_total(a) && !is_total(a) - a = negdegrevlex([x])*negrevlex([y, z, t]) + a = negdegrevlex([x])*neginvlex([y, z, t]) @test is_total(a) && is_total(a) a = negdeglex([x, t, z]) @@ -189,14 +192,14 @@ end R, (x, y, z) = @inferred polynomial_ring(QQ, ["x", "y", "z"]) @test lex([x])*lex([y,z]) == lex([x, y, z]) - @test lex([z])*lex([y])*lex([x]) == revlex([x, y, z]) - @test degrevlex([x, y, z])*revlex([y]) == degrevlex([x, y, z]) + @test lex([z])*lex([y])*lex([x]) == invlex([x, y, z]) + @test degrevlex([x, y, z])*invlex([y]) == degrevlex([x, y, z]) @test deglex([z])*deglex([x])*deglex([y]) == lex([z])*lex([x, y]) @test neglex([x, y])*neglex([z]) == neglex([x, y, z]) @test deglex([x, y, z]) == wdeglex([x, y, z], [1, 1, 1]) @test negdeglex([x, y, z]) == negwdeglex([x, y, z], [1, 1, 1]) @test negdegrevlex([x, y, z]) == negwdegrevlex([x, y, z], [1, 1, 1]) - @test neglex([z])*neglex([y])*neglex([x]) == negrevlex([x, y, z]) + @test neglex([z])*neglex([y])*neglex([x]) == neginvlex([x, y, z]) m = matrix(ZZ, [-1 -1 -1; 1 0 0; 0 1 0; 0 0 1]) @test negdeglex(gens(R)) == matrix_ordering(gens(R), m) @@ -223,7 +226,7 @@ end x1, x4^3, x3*x4^2, x4^2, x3^2*x4, x3*x4, x4, x3^3, x3^2, x3, one(R)] f = sum(M) - o = wdeglex([x1, x2], [1, 2])*revlex([x3, x4]) + o = wdeglex([x1, x2], [1, 2])*invlex([x3, x4]) test_opposite_ordering(o) @test collect(monomials(f; ordering = o)) == M for i in 2:length(M) @@ -236,7 +239,7 @@ end x1*x2*x3, x1*x2, x1^2*x2, x2^2*x4, x2^2*x3, x2^2, x1*x2^2, x2^3] f = sum(M) - o = negrevlex([x1, x2])*wdegrevlex([x3, x4], [1, 2]) + o = neginvlex([x1, x2])*wdegrevlex([x3, x4], [1, 2]) test_opposite_ordering(o) @test collect(monomials(f; ordering = o)) == M for i in 2:length(M) @@ -304,7 +307,7 @@ end wdegrevlex([x1, x2], [1, 2]), negdeglex([x1, x2]), negdegrevlex([x1, x2]), - revlex([x1, x2]), + invlex([x1, x2]), lex([x1, x2])) test_opposite_ordering(a*lex([x3, x4])) @test collect(monomials(x3 + x4; ordering = a*lex([x3, x4]))) == [x3, x4] @@ -314,8 +317,8 @@ end @testset "Polynomial Ordering internal conversion to Singular" begin R, (x, y, s, t, u) = polynomial_ring(QQ, ["x", "y", "s", "t", "u"]) - for O in (wdegrevlex([x,y,s],[1,2,3])*revlex([t,u]), - neglex([x,y,s])*negrevlex([t,u]), + for O in (wdegrevlex([x,y,s],[1,2,3])*invlex([t,u]), + neglex([x,y,s])*neginvlex([t,u]), negdeglex([x,y,s])*negdegrevlex([t,u]), negwdeglex([x,y,s],[1,2,3])*negwdegrevlex([t,u],[1,2])) @test O == monomial_ordering(R, singular(O)) @@ -353,7 +356,7 @@ end K = FreeModule(R, 4) - O5 = revlex(gens(K))*degrevlex(gens(R)) + 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)" @@ -410,11 +413,11 @@ end S, (a, b, c) = polynomial_ring(GF(5), 3) @test lex([a, b]) == induce([a, b], lex([x, y])) - @test revlex([a, b, c]) == induce([a, b, c], revlex([x, y, z])) + @test invlex([a, b, c]) == induce([a, b, c], invlex([x, y, z])) @test degrevlex([a, c]) == induce([a, c], degrevlex([x, z])) M = matrix(ZZ, [1 1 1; 1 0 0; 0 1 0]) @test matrix_ordering([a, b, c], M) == induce([a, b, c], matrix_ordering([x, y, z], M)) @test wdeglex([a, b], [1, 2]) == induce([a, b], wdeglex([x, y], [1, 2])) - @test revlex([a, b])*neglex([c]) == induce([a, b, c], revlex([x, y])*neglex([z])) + @test invlex([a, b])*neglex([c]) == induce([a, b, c], invlex([x, y])*neglex([z])) @test lex([a])*lex([b])*lex([c]) == induce([a, b, c], lex([x])*lex([y])*lex([z])) end