Skip to content

Commit

Permalink
Removing groebner_assure() in MPolyQuo (#2658)
Browse files Browse the repository at this point in the history
  • Loading branch information
ederc authored Aug 23, 2023
1 parent fa11004 commit b514880
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
32 changes: 17 additions & 15 deletions src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
end
end

function groebner_assure(r::MPolyQuoRing)
function groebner_basis(r::MPolyQuoRing)
if isdefined(r, :SQRGB)
return true
end
ordering = r.ordering
groebner_assure(r.I, ordering)
groebner_basis(r.I, ordering=ordering)
oscar_assure(r.I.gb[ordering])
SG = singular_generators(r.I.gb[ordering], ordering)
r.SQR = Singular.create_ring_from_singular_ring(Singular.libSingular.rQuotientRing(SG.ptr, base_ring(SG).ptr))
Expand Down Expand Up @@ -61,10 +61,10 @@ Base.getindex(Q::MPolyQuoRing, i::Int) = Q(base_ring(Q)[i])::elem_type(Q)
base_ring(Q::MPolyQuoRing) = base_ring(Q.I)
coefficient_ring(Q::MPolyQuoRing) = coefficient_ring(base_ring(Q))
modulus(Q::MPolyQuoRing) = Q.I
oscar_groebner_basis(Q::MPolyQuoRing) = groebner_assure(Q) && return Q.I.gb[Q.ordering].O
singular_quotient_groebner_basis(Q::MPolyQuoRing) = groebner_assure(Q) && return Q.SQRGB
singular_origin_groebner_basis(Q::MPolyQuoRing) = groebner_assure(Q) && Q.I.gb[Q.ordering].gens.S
singular_quotient_ring(Q::MPolyQuoRing) = groebner_assure(Q) && Q.SQR
oscar_groebner_basis(Q::MPolyQuoRing) = groebner_basis(Q) && return Q.I.gb[Q.ordering].O
singular_quotient_groebner_basis(Q::MPolyQuoRing) = groebner_basis(Q) && return Q.SQRGB
singular_origin_groebner_basis(Q::MPolyQuoRing) = groebner_basis(Q) && Q.I.gb[Q.ordering].gens.S
singular_quotient_ring(Q::MPolyQuoRing) = groebner_basis(Q) && Q.SQR
singular_poly_ring(Q::MPolyQuoRing; keep_ordering::Bool = false) = singular_quotient_ring(Q)
singular_poly_ring(Q::MPolyQuoRing, ordering::MonomialOrdering) = singular_quotient_ring(Q)
singular_origin_ring(Q::MPolyQuoRing) = base_ring(singular_origin_groebner_basis(Q))
Expand Down Expand Up @@ -186,13 +186,19 @@ function oscar_assure(a::MPolyQuoIdeal)
a.gens.gens.O = [r(g) for g = gens(a.gens.gens.S)]
end

function groebner_assure(a::MPolyQuoIdeal)
function groebner_basis(a::MPolyQuoIdeal)
if !isdefined(a, :gb)
a.gb = IdealGens(base_ring(a), Singular.std(singular_generators(a.gens)))
a.gb.gens.S.isGB = a.gb.isGB = true
end
end

function singular_groebner_generators(a::MPolyQuoIdeal)
groebner_basis(a)

return a.gb.S
end

@doc raw"""
gens(a::MPolyQuoIdeal)
Expand Down Expand Up @@ -638,10 +644,8 @@ true
"""
function ideal_membership(a::MPolyQuoRingElem{T}, b::MPolyQuoIdeal{T}) where T
parent(a) == base_ring(b) || error("base rings must match")
groebner_assure(b)
SR = singular_poly_ring(base_ring(b))
as = simplify(a)
return Singular.iszero(Singular.reduce(SR(as), b.gb.gens.S))
return Singular.iszero(Singular.reduce(SR(simplify(a)), singular_groebner_generators(b)))
end

Base.:in(a::MPolyQuoRingElem, b::MPolyQuoIdeal) = ideal_membership(a, b)
Expand Down Expand Up @@ -673,9 +677,8 @@ true
"""
function is_subset(a::MPolyQuoIdeal{T}, b::MPolyQuoIdeal{T}) where T
@req base_ring(a) == base_ring(b) "base rings must match"
as = simplify(a)
groebner_assure(b)
return Singular.iszero(Singular.reduce(as.gens.S, b.gb.gens.S))
simplify(a)
return Singular.iszero(Singular.reduce(singular_generators(a.gens), singular_groebner_generators(b)))
end

@doc raw"""
Expand Down Expand Up @@ -1518,8 +1521,7 @@ function dim(a::MPolyQuoIdeal)
if a.dim > -1
return a.dim
end
groebner_assure(a)
a.dim = Singular.dimension(a.gb.S)
a.dim = Singular.dimension(singular_groebner_generators(a))
return a.dim
end

Expand Down
3 changes: 1 addition & 2 deletions src/Rings/groebner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1482,8 +1482,7 @@ end

# modular gröbner basis techniques using Singular
@doc raw"""
groebner_basis_modular(I::MPolyIdeal{fmpq_mpoly}; ordering::MonomialOrdering = default_ordering(base_ring(I)),
certify::Bool = false)
groebner_basis_modular(I::MPolyIdeal{fmpq_mpoly}; ordering::MonomialOrdering = default_ordering(base_ring(I)), certify::Bool = false)
Compute the reduced Gröbner basis of `I` w.r.t. `ordering` using a
multi-modular strategy.
Expand Down

0 comments on commit b514880

Please sign in to comment.