Skip to content

Commit

Permalink
Fixes for the degree function (#3298)
Browse files Browse the repository at this point in the history
* Remove :task from sub methods for modules.

* Introduce new function submodule.

* Remove all deprecated uses of sub.

* Export submodule.

* Fix tests.

* Fix tests again.

* Register morphisms in general.

* Rebase network of natural maps on WeakKeyIdDicts.

* Clean up the morphisms network and dont store the actual morphisms.

* Some small fix for Wolfram.

* Some fixes and marking the test as broken again.

* Fix documentation.

* Another small fix for Wolfram.

* Fix the fix.

* Fix method selection.

* Introduce kw argument for caching morphisms.

* Redirect previous usages.

* Adjust tests.

* submodule -> sub_object.

* Fix docstrings and signatures for quo.

* Fix methods for quo.

* Adjust documentation.

* Fix up usages of quo.

* Export new functions.

* Some fixes.

* Fix tests.

* Fix tests.

* Fix tests.

* Fix tests.

* Fix tests.

* Fix tests.

* Squashed changes.

* Fix tests.

* Fix up the truncation.

* New rebase.

* Fix tests.

* WIP with debug messages.

* Progress in debugging.

* WIP on debugging.

* Write truely generic presentation and kernel methods [no ci].

* Repair graded_map to accept zero entries.

* Add tensor decomposition function to return value.

* Add some assertions.

* Repair kernel routine.

* Rewrite hom methods for modules.

* Add generic method for simplification of SubquoModuleElems.

* Add missing check argument.

* Fix or disable brittle tests.

* Fix faulty merge.

* Go back to old hom.

* Switch tests to old hom.

* Clean up some deprecated assertions.

* Repair truncate.

* Disable internal checks.

* Update docs/src/CommutativeAlgebra/ModulesOverMultivariateRings/free_modules.md

* Revert "Go back to old hom."

This reverts commit a6b7c15.

* Revert "Switch tests to old hom."

This reverts commit 178eaf3.

* Disable duplicate method.

* Adjust printing.

* Fix tests.

* Fix keyword argument for duals.

* Fix doctests.

* Fix tests.

* Fix doctests.

* Delete some falsely added files.

* Remove deprecated code.

* Another round of disabling internal checks.

* Disable various internal checks.

* Disable further internal checks.

* Set random seeds in tests.

* Adjust use of keyword argument.

* Fix more random seeds.

* Fix the generic simplify method for SubquoModuleElems.

* Revert "Remove deprecated code."

This reverts commit 190256b.

* Repair revert to old hom.

* Repair preimage function.

* Repair degree function.

* Adjust tests to use of repaired old hom.

* Add dummy simplify function for FreeModuleElems.

* Fix doctests.

* Repair simplify.

* Fix documentation.

* Fix doctests.

* Some tuning.

* Fix tests.

* Bugfix from running book code run.

* Remove some debugging artifacts.

* Fix faulty merge.

* Restrict signature.

* Update flattenings of modules over towers of polynomial rings to make the tests run again.

* Small fix.

* Disable the superfluous kernel routine.

* Restrict some further signatures to cases Singular can handle.

* Add tests for flattenings of modules.

* Readd methods which are not superfluous, yet.

---------

Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
  • Loading branch information
3 people committed Feb 21, 2024
1 parent 69006c7 commit cfb3413
Show file tree
Hide file tree
Showing 47 changed files with 1,739 additions and 749 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ is_homogeneous(f::FreeModElem)
```

```@docs
degree(f::FreeModElem)
degree(f::FreeModElem{T}) where {T<:Union{<:MPolyDecRingElem, <:MPolyQuoRingElem{<:MPolyDecRingElem}}}
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T
## Truncation

```@docs
truncate(M::ModuleFP, g::FinGenAbGroupElem, task::Symbol = :with_morphism)
truncate(M::ModuleFP, g::FinGenAbGroupElem, task::Symbol=:with_morphism)
```

## Twists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ intersect(M::SubquoModule{T}, N::SubquoModule{T}) where T
## Submodules and Quotients

```@docs
sub(M::ModuleFP{T}, V::Vector{<:ModuleFPElem{T}}, task::Symbol = :with_morphism) where T
sub(M::ModuleFP{T}, V::Vector{<:ModuleFPElem{T}}) where T
```

```@docs
quo(M::ModuleFP{T}, V::Vector{<:ModuleFPElem{T}}, task::Symbol = :with_morphism) where T
quo(M::ModuleFP{T}, V::Vector{<:ModuleFPElem{T}}; cache_morphism::Bool=false) where T
```

## Homomorphisms From Subqotients
Expand Down
2 changes: 1 addition & 1 deletion docs/src/CommutativeAlgebra/homological_algebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ homology(C::ComplexOfMorphisms{<:ModuleFP}, i::Int)
## Hom and Ext

```@docs
hom(M::ModuleFP, N::ModuleFP, algorithm::Symbol=:maps)
hom(M::ModuleFP, N::ModuleFP; algorithm::Symbol=:maps)
```

```@docs
Expand Down
10 changes: 5 additions & 5 deletions experimental/DoubleAndHyperComplexes/src/Morphisms/ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ function (fac::HomMapFactory)(hc::AbsHyperComplex, p::Int, i::Tuple)
cod = hc[i_inc]

if iszero(dom) || iszero(cod)
return hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)])
return hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)]; check=false)
end

if p <= dim(d)
# contravariant induced map on first argument
i1_inc = Tuple(-i1 - [k == p ? inc : 0 for k in 1:dim(d)])
img_gens = [homomorphism_to_element(cod, compose(map(d, p, i1_inc), element_to_homomorphism(g))) for g in gens(dom)]
return hom(dom, cod, img_gens)
return hom(dom, cod, img_gens; check=false)
else
# covariant induced map on second argument
img_gens = [homomorphism_to_element(cod, compose(element_to_homomorphism(g), map(c, p - dim(d), Tuple(i2)))) for g in gens(dom)]
return hom(dom, cod, img_gens)
return hom(dom, cod, img_gens; check=false)
end
end

Expand Down Expand Up @@ -214,7 +214,7 @@ function (fac::InterpretationMorphismFactory)(self::AbsHyperComplexMorphism, I::
projections_tot = projections_for_summand(tot, offset)
M = dom[i]
N = cod[j]
result = hom(M, N, elem_type(N)[zero(N) for i in 1:ngens(M)])
result = hom(M, N, elem_type(N)[zero(N) for i in 1:ngens(M)]; check=false)
for (k, K) in enumerate(indices_dom)
pr = projections_dom[k]
for (l, L) in enumerate(indices_cod)
Expand Down Expand Up @@ -341,7 +341,7 @@ function (fac::HomComplexMorphismFactory)(self::AbsHyperComplexMorphism, I::Tupl
img_gens = elem_type(cod_mod)[homomorphism_to_element(cod_mod, compose(element_to_homomorphism(v), fac.codomain_morphism[I_out])) for v in g]
end

return hom(dom_mod, cod_mod, img_gens) # Set to false eventually
return hom(dom_mod, cod_mod, img_gens; check=false) # Set to false eventually
end

function can_compute(fac::HomComplexMorphismFactory, self::AbsHyperComplexMorphism, I::Tuple)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ function (fac::ResolutionModuleFactory{ChainType})(c::AbsHyperComplex, I::Tuple)
end

if isone(i)
aug = hom(c[0], fac.orig_mod, gens(fac.orig_mod))
aug = hom(c[0], fac.orig_mod, gens(fac.orig_mod); check=false)
aug.generators_map_to_generators = true
K, inc = kernel(aug)
next = _make_free_module(K, gens(K))
phi = hom(next, c[0], ambient_representatives_generators(K))
phi = hom(next, c[0], ambient_representatives_generators(K); check=false)
push!(fac.map_cache, phi)
return next
end
Expand All @@ -45,7 +46,7 @@ function (fac::ResolutionModuleFactory{ChainType})(c::AbsHyperComplex, I::Tuple)
return next
end
next = _make_free_module(K, gens(K))
phi = hom(next, c[i-1], ambient_representatives_generators(K))
phi = hom(next, c[i-1], ambient_representatives_generators(K); check=false)
push!(fac.map_cache, phi)

return next
Expand All @@ -54,10 +55,10 @@ end
function zero_object(M::ModuleFP)
if is_graded(M)
result = graded_free_module(base_ring(M), [])
return result, hom(result, M, elem_type(M)[])
return result, hom(result, M, elem_type(M)[]; check=false)
else
result = FreeMod(base_ring(M), 0)
return result, hom(result, M, elem_type(M)[])
return result, hom(result, M, elem_type(M)[]; check=false)
end
end

Expand Down Expand Up @@ -99,7 +100,8 @@ function free_resolution(::Type{T}, M::SubquoModule{RET}) where {T<:SimpleFreeRe
)
result = SimpleFreeResolution(M, internal_complex)
MC = ZeroDimensionalComplex(M)[0:0] # Wrap MC as a 1-dimensional complex concentrated in degree 0
aug_map = hom(result[(0,)], M, gens(M)) # The actual augmentation map
aug_map = hom(result[(0,)], M, gens(M); check=false) # The actual augmentation map
aug_map.generators_map_to_generators = true
aug_map_comp = MorphismFromDict(result, MC, Dict{Tuple, typeof(aug_map)}([(0,)=>aug_map]))
result.augmentation_map = aug_map_comp
return result, aug_map_comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
# Create the maps to the old complex
img_gens_dom = elem_type(M)[sum(c*M[j] for (j, c) in S[i]; init=zero(M)) for i in I]
new_dom = _make_free_module(M, img_gens_dom)
dom_map = hom(new_dom, M, img_gens_dom)
dom_map = hom(new_dom, M, img_gens_dom; check=false)

if haskey(fac.maps_to_original, i)
# This means that for the next map a partial or
Expand All @@ -93,7 +93,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)

img_gens_cod = elem_type(N)[sum(c*N[i] for (i, c) in T[j]; init=zero(N)) for j in J]
new_cod = _make_free_module(N, img_gens_cod)
cod_map = hom(new_cod, N, img_gens_cod)
cod_map = hom(new_cod, N, img_gens_cod; check=false)

if haskey(fac.maps_to_original, next)
fac.maps_to_original[next] = compose(cod_map, fac.maps_to_original[next])
Expand Down Expand Up @@ -122,7 +122,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
# end
push!(img_gens_dom, v)
end
dom_map_inv = hom(M, new_dom, img_gens_dom)
dom_map_inv = hom(M, new_dom, img_gens_dom; check=false)

if haskey(fac.maps_from_original, i)
fac.maps_from_original[i] = compose(fac.maps_from_original[i], dom_map_inv)
Expand All @@ -144,7 +144,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
w_new = sparse_row(base_ring(w), new_entries)
push!(img_gens_cod, FreeModElem(w_new, new_cod))
end
cod_map_inv = hom(N, new_cod, img_gens_cod)
cod_map_inv = hom(N, new_cod, img_gens_cod; check=false)

if haskey(fac.maps_from_original, next)
fac.maps_from_original[next] = compose(fac.maps_from_original[next], cod_map_inv)
Expand Down Expand Up @@ -184,7 +184,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
# Create the maps to the old complex
img_gens_dom = elem_type(M)[sum(c*M[j] for (j, c) in S[i]; init=zero(M)) for i in I]
new_dom = _make_free_module(M, img_gens_dom)
dom_map = hom(new_dom, M, img_gens_dom)
dom_map = hom(new_dom, M, img_gens_dom; check=false)

if haskey(fac.maps_to_original, prev)
fac.maps_to_original[prev] = compose(dom_map, fac.maps_to_original[prev])
Expand All @@ -195,7 +195,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)

img_gens_cod = elem_type(N)[sum(c*N[i] for (i, c) in T[j]; init=zero(N)) for j in J]
new_cod = _make_free_module(N, img_gens_cod)
cod_map = hom(new_cod, N, img_gens_cod)
cod_map = hom(new_cod, N, img_gens_cod; check=false)

if haskey(fac.maps_to_original, i)
fac.maps_to_original[i] = compose(cod_map, fac.maps_to_original[i])
Expand All @@ -214,7 +214,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
end
push!(img_gens_dom, v)
end
dom_map_inv = hom(M, new_dom, img_gens_dom)
dom_map_inv = hom(M, new_dom, img_gens_dom; check=false)

if haskey(fac.maps_from_original, prev)
fac.maps_from_original[prev] = compose(fac.maps_from_original[prev], dom_map_inv)
Expand All @@ -235,7 +235,7 @@ function (fac::SimplifiedChainFactory)(d::AbsHyperComplex, Ind::Tuple)
w_new = sparse_row(base_ring(w), new_entries)
push!(img_gens_cod, FreeModElem(w_new, new_cod))
end
cod_map_inv = hom(N, new_cod, img_gens_cod)
cod_map_inv = hom(N, new_cod, img_gens_cod; check=false)

if haskey(fac.maps_from_original, i)
fac.maps_from_original[i] = compose(fac.maps_from_original[i], cod_map_inv)
Expand Down Expand Up @@ -357,7 +357,7 @@ end
### Helper functions
function _make_free_module(M::ModuleFP, g::Vector{T}) where {T<:ModuleFPElem}
if is_graded(M)
w = degree.(g)
w = _degree_fast.(g)
return graded_free_module(base_ring(M), w)
else
return FreeMod(base_ring(M), length(g))
Expand Down Expand Up @@ -598,9 +598,9 @@ function _alt_simplify(M::SubquoModule)
Z0, inc_Z0 = kernel(simp, 0)

result_to_M = hom(result, M,
elem_type(M)[aug[0](simp_to_orig[0](inc_Z0(preimage(Z0_to_result, x)))) for x in gens(result)])
elem_type(M)[aug[0](simp_to_orig[0](inc_Z0(preimage(Z0_to_result, x)))) for x in gens(result)]; check=false)
M_to_result = hom(M, result,
elem_type(result)[Z0_to_result(preimage(inc_Z0, orig_to_simp[0](preimage(aug[0], y)))) for y in gens(M)])
elem_type(result)[Z0_to_result(preimage(inc_Z0, orig_to_simp[0](preimage(aug[0], y)))) for y in gens(M)]; check=false)
return result, M_to_result, result_to_M
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function (fac::KoszulMorphismFactory)(c::AbsHyperComplex, p::Int, i::Tuple)
dom = c[i]
cod = c[first(i) - 1]
if first(i) == 0 || first(i) == r + 1
return hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)])
return hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)]; check=false)
end
return wedge_multiplication_map(dom, cod, fac.v)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function (fac::TotalComplexMapFactory)(c::AbsHyperComplex, p::Int, I::Tuple)
next = d + inc
dom = c[d]
cod = c[next]
result = hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)])
result = hom(dom, cod, elem_type(cod)[zero(cod) for i in 1:ngens(dom)]; check=false)
for (ind, J) in enumerate(index_cache(chain_fac)[d])
for k in 1:dim(orig)
target = collect(J) + (direction(orig, k) == :chain ? -1 : 1)*[(l == k ? 1 : 0) for l in 1:dim(orig)]
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/DerivedPushforward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function rank(phi::FreeModuleHom{FreeMod{T}, FreeMod{T}, Nothing}) where {T<:Fie
end


_regularity_bound(F::FreeMod) = maximum(Int(degree(a)[1]) for a in gens(F))
_regularity_bound(F::FreeMod) = maximum(Int(degree(a; check=false)[1]) for a in gens(F))

@doc raw"""
simplify(c::ComplexOfMorphisms{ChainType}) where {ChainType<:ModuleFP}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function ambient_embedding(X::AbsProjectiveScheme)
S = homogeneous_coordinate_ring(IP)
T = homogeneous_coordinate_ring(X)
I = defining_ideal(X)
pb = hom(S, T, gens(T))
pb = hom(S, T, gens(T); check=false)
inc_sub = ProjectiveSchemeMor(X, IP, pb, check=false)
return ProjectiveClosedEmbedding(inc_sub, I, check=false)
end
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ with default covering
u = inv(OO(U_ij)(denom))
mor_dict[U_ij] = morphism(U_ij, V_j,
hom(OO(V_j), OO(U_ij),
[OO(U_ij)(dehom(pbf(gen(SY, k))))*u for k in 1:ngens(SY) if k != j]
[OO(U_ij)(dehom(pbf(gen(SY, k))))*u for k in 1:ngens(SY) if k != j];
check=false
)
)
end
Expand Down Expand Up @@ -120,11 +121,11 @@ function pushforward(inc::ProjectiveClosedEmbedding, M::FreeMod)
S = codomain(f)
T = domain(f)
S === base_ring(M) || error("rings do not match")
FT = graded_free_module(T, [degree(a) for a in gens(M)])
FT = graded_free_module(T, [_degree_fast(a) for a in gens(M)])
I = image_ideal(inc)
IFT, inc_IFT = I*FT
MT = cokernel(inc_IFT)
id = hom(MT, M, gens(M), f)
id = hom(MT, M, gens(M), f; check=false)
return MT, id
end

Expand All @@ -141,7 +142,7 @@ function pushforward(inc::ProjectiveClosedEmbedding, M::SubquoModule)
G, inc_G = sub(FT, vcat(gT, relT))
Q, inc_Q = sub(G, gens(G)[length(gT)+1:end])
MT = cokernel(inc_Q)
id = hom(MT, M, vcat(gens(M), elem_type(M)[zero(M) for i in 1:length(relT)]))
id = hom(MT, M, vcat(gens(M), elem_type(M)[zero(M) for i in 1:length(relT)]); check=false)
return MT, id
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,10 @@ function relative_euler_sequence(X::AbsProjectiveScheme{<:Ring, <:MPolyRing})
S = homogeneous_coordinate_ring(X)::MPolyDecRing
W1 = kaehler_differentials(S)
W0 = kaehler_differentials(S, 0)
theta = hom(W1, W0, [x*W0[1] for x in gens(S)])
theta = hom(W1, W0, [x*W0[1] for x in gens(S)]; check=false)
W, inc = kernel(theta)
Z = graded_free_module(S, 0)
inc_Z = hom(Z, W, elem_type(W)[])
inc_Z = hom(Z, W, elem_type(W)[]; check=false)
comp = ComplexOfMorphisms(ModuleFP, [inc_Z, inc, theta], typ=:cochain, seed = -1)
return comp
end
Expand Down Expand Up @@ -578,10 +578,10 @@ function relative_cotangent_module(X::AbsProjectiveScheme{<:Ring, <:MPolyQuoRing

SP = homogeneous_coordinate_ring(P)
F = graded_free_module(SP, degree.(f))
jac = hom(F, eu[1], df)
jac = hom(F, eu[1], df; check=false)
jac_res = _change_base_ring_and_preserve_gradings(phi, jac, codomain_change = res_Omega1)
img_gens = [preimage(inc_W1X, jac_res(x)) for x in gens(domain(jac_res))]
psi = hom(domain(jac_res), W1X, img_gens)
psi = hom(domain(jac_res), W1X, img_gens; check=false)
return cokernel(psi)
end

2 changes: 1 addition & 1 deletion src/Modules/ExteriorPowers/FreeModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function exterior_power(F::FreeMod, p::Int; cached::Bool=true)
G = grading_group(F)
weights = elem_type(G)[]
for ind in OrderedMultiIndexSet(p, n)
push!(weights, sum(degree(F[i]) for i in indices(ind); init=zero(G)))
push!(weights, sum(_degree_fast(F[i]) for i in indices(ind); init=zero(G)))
end
grade(result_, weights)
else
Expand Down
8 changes: 4 additions & 4 deletions src/Modules/ExteriorPowers/Generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ function wedge_multiplication_map(F::ModuleFP, G::ModuleFP, v::ModuleFPElem)
success, orig_mod, p = _is_exterior_power(F)
if !success
Fwedge1, _ = exterior_power(F, 1)
id = hom(F, Fwedge1, gens(Fwedge1))
id = hom(F, Fwedge1, gens(Fwedge1); check=false)
tmp = wedge_multiplication_map(Fwedge1, G, v)
return compose(id, tmp)
end

success, orig_mod_2, q = _is_exterior_power(G)
if !success
Gwedge1, _ = exterior_power(G, 1)
id = hom(Gwedge1, G, gens(G))
id = hom(Gwedge1, G, gens(G); check=false)
tmp = wedge_multiplication_map(F, Gwedge1, v)
return compose(tmp, id)
end
Expand All @@ -93,7 +93,7 @@ function wedge_multiplication_map(F::ModuleFP, G::ModuleFP, v::ModuleFPElem)

# map the generators
img_gens = [wedge(v, e, parent=G) for e in gens(F)]
return hom(F, G, img_gens)
return hom(F, G, img_gens; check=false)
end

# The wedge product of two or more elements.
Expand Down Expand Up @@ -177,7 +177,7 @@ function induced_map_on_exterior_power(phi::FreeModuleHom{<:FreeMod, <:FreeMod,

imgs = phi.(gens(F))
img_gens = [wedge(imgs[indices(ind)], parent=codomain) for ind in OrderedMultiIndexSet(p, m)]
return hom(domain, codomain, img_gens)
return hom(domain, codomain, img_gens; check=false)
end

# The induced map on exterior powers
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/FreeModules-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ function hom(M::ModuleFP_dec, N::ModuleFP_dec)
psi = kDelta[2]*pro[1]
psi = hom(kDelta[1], H_s0_t0, [psi(g) for g = gens(kDelta[1])])

H = quo(sub(D, kDelta[1]), image(rho)[1])
H = quo_object(sub(D, kDelta[1]), image(rho)[1])
set_attribute!(H, :show => Hecke.show_hom, :hom => (M, N))

#x in ker delta: mH_s0_t0(pro[1](x)) should be a hom from M to N
Expand Down
Loading

0 comments on commit cfb3413

Please sign in to comment.