Skip to content

Commit

Permalink
Make radical computation actually work over extensions of QQ.
Browse files Browse the repository at this point in the history
  • Loading branch information
HechtiDerLachs committed Sep 24, 2024
1 parent accc8e1 commit 93c4575
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/Rings/mpoly-ideals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,19 @@ Ideal generated by
3*a*b*c
```
"""
@attr T function radical(I::T) where {T <: MPolyIdeal}
@attr MPolyIdeal{T} function radical(I::MPolyIdeal{T}) where {T <: MPolyRingElem}
# Calling `elimpart` (within `simplify`) turns out to significantly speed things up in many cases.
R = base_ring(I)
Q, pr = quo(R, I)
S, iso, iso_inv = simplify(Q)
J = modulus(S)
pre_res = _compute_radical(J)
res = ideal(R, elem_type(R)[lift(iso_inv(S(g))) for g in gens(pre_res)]) + I
set_attribute!(res, :is_radical=>true)
return res
end

function _compute_radical(I::T) where {T <: MPolyIdeal}
R = base_ring(I)
if isa(base_ring(R), NumField) && !isa(base_ring(R), AbsSimpleNumField)
A, mA = absolute_simple_field(base_ring(R))
Expand Down Expand Up @@ -629,7 +641,7 @@ end

function map_coefficients(mp, I::MPolyIdeal; parent = nothing)
if parent === nothing
parent = Oscar.parent(map_coefficients(mp, gen(I, 1)))
parent = Oscar.parent(map_coefficients(mp, zero(base_ring(I))))
end
return ideal(parent, [map_coefficients(mp, g, parent = parent) for g = gens(I)])
end
Expand All @@ -642,12 +654,10 @@ Return whether `I` is a radical ideal.
Computes the radical.
"""
@attr Bool function is_radical(I::MPolyIdeal)
if has_attribute(I, :is_prime) && is_prime(I)
return true
end

return I == radical(I)
has_attribute(I, :is_prime) && return is_prime(I)
return is_subset(radical(I), I)
end

#######################################################
@doc raw"""
primary_decomposition(I::MPolyIdeal; algorithm = :GTZ, cache=true)
Expand Down Expand Up @@ -1149,7 +1159,14 @@ function minimal_primes(
end
J = K
end
result = unique!(filter!(!is_one, vcat([minimal_primes(j; algorithm, factor_generators=false) for j in J]...)))
# unique! seems to fail here. We have to do it manually.
pre_result = filter!(!is_one, vcat([minimal_primes(j; algorithm, factor_generators=false) for j in J]...))
result = typeof(I)[]
for p in pre_result
p in result && continue
push!(result, p)
end

# The list might not consist of minimal primes only. We have to discard the embedded ones
final_list = typeof(I)[]
for p in result
Expand Down Expand Up @@ -1209,7 +1226,7 @@ julia> L = equidimensional_decomposition_weak(I)
Ideal with 1 generator
```
"""
@attr Any function equidimensional_decomposition_weak(I::MPolyIdeal)
@attr Vector{typeof(I)} function equidimensional_decomposition_weak(I::MPolyIdeal)
R = base_ring(I)
iszero(I) && return [I]
@req coefficient_ring(R) isa AbstractAlgebra.Field "The coefficient ring must be a field"
Expand All @@ -1235,7 +1252,7 @@ julia> L = equidimensional_decomposition_weak(I)
return V
end

@attr Any function equidimensional_decomposition_weak(
@attr Vector{typeof(I)} function equidimensional_decomposition_weak(
I::MPolyIdeal{T}
) where {U<:Union{AbsSimpleNumFieldElem, <:Hecke.RelSimpleNumFieldElem}, T<:MPolyRingElem{U}}
R = base_ring(I)
Expand Down

0 comments on commit 93c4575

Please sign in to comment.