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

Free resolutions updates #2836

Merged
merged 7 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Modules/UngradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6355,7 +6355,7 @@ function _get_last_map_key(cc::Hecke.ComplexOfMorphisms)
return last(Hecke.map_range(cc))
end

function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int; algorithm::Symbol=:fres)
function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int)
# assuming a free res is a chain_complex, then it will be
# M_1 -> M_0 -> S -> 0
#the range is 1:-1:-2 or so
Expand All @@ -6364,14 +6364,19 @@ function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int; algorit
# - extending lift is repeated pushfirst
# - the idx is only used to see how many maps are missing

algorithm = get_attribute(cc, :algorithm)
if algorithm == nothing
algorithm = :fres
set_attribute!(cc, :algorithm, :fres)
end
r = Hecke.map_range(cc)
if idx < last(r)
error("extending past the final zero not supported")
end
len_missing = idx - first(r)
@assert len_missing > 0
if cc.complete == true
error("complex is complete, cannot extend")
return map(cc, first(r))
end

kernel_entry = image(cc.maps[1])[1]
Expand All @@ -6386,6 +6391,10 @@ function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int; algorit
res = Singular.fres(singular_kernel_entry, len, "complete")
elseif algorithm == :lres
error("LaScala's method is not yet available in Oscar.")
elseif algorithm == :mres
res = Singular.mres(singular_kernel_entry, len)
elseif algorithm == :nres
res = Singular.nres(singular_kernel_entry, len)
else
error("Unsupported algorithm $algorithm")
end
Expand All @@ -6394,16 +6403,19 @@ function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int; algorit
j = 2

while j <= Singular.length(res)
rk = Singular.ngens(res[j])
if is_graded(dom)
codom = dom
SM = SubModuleOfFreeModule(codom, res[j])
generator_matrix(SM)
map = graded_map(codom, SM.matrix)
dom = domain(map)
set_attribute!(dom, :name => "R^$rk")
else
codom = dom
dom = free_module(br, Singular.ngens(res[j]))
SM = SubModuleOfFreeModule(codom, res[j])
set_attribute!(dom, :name => "R^$rk")
generator_matrix(SM)
map = hom(dom, codom, SM.matrix)
end
Expand All @@ -6417,7 +6429,9 @@ function _extend_free_resolution(cc::Hecke.ComplexOfMorphisms, idx::Int; algorit
pushfirst!(cc, hom(Z, domain(cc.maps[1]), Vector{elem_type(domain(cc.maps[1]))}()))
cc.complete = true
end
return map(cc, idx)
set_attribute!(cc, :show => free_show)
maxidx = min(idx, first(Hecke.map_range(cc)))
return map(cc, maxidx)
end

@doc raw"""
Expand Down Expand Up @@ -6576,6 +6590,7 @@ function free_resolution(M::SubquoModule{<:MPolyRingElem};
cc.fill = _extend_free_resolution
cc.complete = cc_complete
set_attribute!(cc, :show => free_show, :free_res => M)
set_attribute!(cc, :algorithm, algorithm)

return FreeResolution(cc)
end
Expand Down
3 changes: 3 additions & 0 deletions test/Modules/UngradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ end
@test length(free_res.C.maps) == 4
@test free_res[3] == free_module(R, 2)
@test free_res[4] == free_module(R, 0)
@test free_res[100] == free_module(R, 0)
@test is_complete(free_res) == true
free_res = free_resolution(M)
@test get_attribute(free_res.C, :algorithm) == :fres
@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 get_attribute(free_res.C, :algorithm) == :mres
@test all(iszero, homology(free_res.C))
free_res = free_resolution(M, algorithm = :nres)
@test all(iszero, homology(free_res.C))
Expand Down