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

Add mres and nres Singular Calls for Free resolutions #2500

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions src/Modules/UngradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6215,11 +6215,13 @@
@doc raw"""
free_resolution(F::FreeMod)

Return a free resolution of `F`.
Return a free resolution of `F`. The `length` and `algorithm`
keywords are here only for compatibility reasons with the other `free_resolution`
methods and have no effect on the computation.

Check warning on line 6220 in src/Modules/UngradedModules.jl

View check run for this annotation

Codecov / codecov/patch

src/Modules/UngradedModules.jl#L6218-L6220

Added lines #L6218 - L6220 were not covered by tests

# Examples
"""
function free_resolution(F::FreeMod)
function free_resolution(F::FreeMod; length::Int=0, algorithm::Symbol=:fres)
res = presentation(F)
set_attribute!(res, :show => free_show, :free_res => F)
return FreeResolution(res)
Expand Down Expand Up @@ -6371,7 +6373,8 @@
Return a free resolution of `M`.

If `length != 0`, the free resolution is only computed up to the `length`-th free module.
At the moment, `algorithm` only allows the option `:fres`.
At the moment, options for `algorithm` are `:fres`, `:mres` and `:nres`. With `:mres` or `:nres`,
minimal free resolutions are returned.

# Examples
```jldoctest
Expand Down Expand Up @@ -6425,9 +6428,8 @@
iterative kernel computation.
"""
function free_resolution(M::SubquoModule{<:MPolyRingElem};
ordering::ModuleOrdering = default_ordering(M),
length::Int=0, algorithm::Symbol=:fres
)
ordering::ModuleOrdering = default_ordering(M),
length::Int=0, algorithm::Symbol=:fres)

coefficient_ring(base_ring(M)) isa AbstractAlgebra.Field ||
error("Must be defined over a field.")
Expand All @@ -6436,13 +6438,13 @@

#= Start with presentation =#
pm = presentation(M)
maps = [map(pm, j) for j in Hecke.map_range(pm)]
maps = [pm.maps[j] for j in 2:3]

br = base_ring(M)
kernel_entry = image(pm.maps[1])[1]

if ngens(kernel_entry) == 0
cc = Hecke.ComplexOfMorphisms(Oscar.ModuleFP, maps, check = false, seed = -2)
cc = Hecke.ComplexOfMorphisms(Oscar.ModuleFP, pushfirst!(maps, pm.maps[1]), check = false, seed = -2)
cc.fill = _extend_free_resolution
cc.complete = true
return FreeResolution(cc)
Expand All @@ -6459,6 +6461,12 @@
elseif algorithm == :lres
error("LaScala's method is not yet available in Oscar.")
gbpres = singular_kernel_entry # or as appropriate, taking into account base changes
elseif algorithm == :mres
gbpres = singular_kernel_entry
res = Singular.mres(gbpres, length)
elseif algorithm == :nres
gbpres = singular_kernel_entry
res = Singular.nres(gbpres, length)
else
error("Unsupported algorithm $algorithm")
end
Expand All @@ -6467,34 +6475,17 @@
cc_complete = true
end

codom = codomain(maps[1])

if is_graded(codom)
rk = Singular.ngens(gbpres)
SM = SubModuleOfFreeModule(codom, gbpres)
generator_matrix(SM)
ff = graded_map(codom, SM.matrix)
dom = domain(ff)
else
dom = free_module(br, Singular.ngens(gbpres))
SM = SubModuleOfFreeModule(codom, gbpres)
generator_matrix(SM)
ff = hom(dom, codom, SM.matrix)
end

maps[1] = ff

br_name = AbstractAlgebra.find_name(base_ring(M))
if br_name === nothing
br_name = "R"
end

#= Add maps from free resolution computation, start with second entry
= due to inclusion of presentation(M) at the beginning. =#
j = 2
j = 1
while j <= Singular.length(res)
if is_graded(dom)
codom = dom
if is_graded(M)
codom = domain(maps[1])
rk = Singular.ngens(res[j])
SM = SubModuleOfFreeModule(codom, res[j])
generator_matrix(SM)
Expand All @@ -6504,7 +6495,7 @@
insert!(maps, 1, ff)
j += 1
else
codom = dom
codom = domain(maps[1])
rk = Singular.ngens(res[j])
dom = free_module(br, rk)
SM = SubModuleOfFreeModule(codom, res[j])
Expand Down Expand Up @@ -6642,35 +6633,45 @@
end

@doc raw"""
free_resolution(I::MPolyIdeal)
free_resolution(I::MPolyIdeal; length::Int=0, algorithm::Symbol=:fres)

Compute a free resolution of `I`.

If `length != 0`, the free resolution is only computed up to the `length`-th free module.
At the moment, options for `algorithm` are `:fres`, `:mres` and `:nres`. With `:mres` or `:nres`,
minimal free resolutions are returned.

Check warning on line 6643 in src/Modules/UngradedModules.jl

View check run for this annotation

Codecov / codecov/patch

src/Modules/UngradedModules.jl#L6643

Added line #L6643 was not covered by tests
# Examples
"""
function free_resolution(I::MPolyIdeal)
function free_resolution(I::MPolyIdeal;
length::Int=0, algorithm::Symbol=:fres)
S = ideal_as_module(I)
n = Hecke.find_name(I)
if n !== nothing
AbstractAlgebra.set_name!(S, string(n))
end
return free_resolution(S)
return free_resolution(S, length = length, algorithm = algorithm)
end

@doc raw"""
free_resolution(Q::MPolyQuoRing)
free_resolution(Q::MPolyQuoRing; length::Int=0, algorithm::Symbol=:fres)

Compute a free resolution of `Q`.

If `length != 0`, the free resolution is only computed up to the `length`-th free module.
At the moment, options for `algorithm` are `:fres`, `:mres` and `:nres`. With `:mres` or `:nres`,
minimal free resolutions are returned.

# Examples
"""
function free_resolution(Q::MPolyQuoRing)
function free_resolution(Q::MPolyQuoRing;
length::Int=0, algorithm::Symbol=:fres)
q = quotient_ring_as_module(Q)
n = Hecke.find_name(Q)
if n !== nothing
AbstractAlgebra.set_name!(q, String(n))
end
return free_resolution(q)
return free_resolution(q, length = length, algorithm = algorithm)
end

@doc raw"""
Expand Down
26 changes: 15 additions & 11 deletions test/Modules/UngradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,25 @@ end
@test is_bijective(p)
end

R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"])
A = R[x; y]
B = R[x^2; x*y; y^2; z^4]
M = SubquoModule(A, B)
free_res = free_resolution(M, length=1)
R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"])
A = R[x; y]
B = R[x^2; x*y; y^2; z^4]
M = SubquoModule(A, B)
free_res = free_resolution(M, length=1)
@test is_complete(free_res) == false
free_res[2]
@test length(free_res.C.maps) == 4
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved
@test free_res[3] == free_module(R, 2)
@test free_res[4] == free_module(R, 0)
@test free_res[3] == free_module(R, 2)
@test free_res[4] == free_module(R, 0)
@test is_complete(free_res) == true
free_res = free_resolution(M)
@test all(iszero, homology(free_res.C))
free_res = free_resolution_via_kernels(M)
@test all(iszero, homology(free_res))
free_res = free_resolution(M)
@test all(iszero, homology(free_res.C))
free_res = free_resolution_via_kernels(M)
@test all(iszero, homology(free_res))
free_res = free_resolution(M, algorithm = :mres)
@test all(iszero, homology(free_res.C))
free_res = free_resolution(M, algorithm = :nres)
@test all(iszero, homology(free_res.C))

N = SubquoModule(R[x+2*x^2; x+y], R[z^4;])
tensor_resolution = tensor_product(N,free_res)
Expand Down
Loading