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

Resolve unbound type parameters #4363

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ cokernel(a::ModuleFPHom)
## Direct Sums and Products

```@docs
direct_sum(M::ModuleFP{T}...; task::Symbol = :sum) where T
direct_sum(M::ModuleFP{T}, Ms::ModuleFP{T}...; task::Symbol = :sum) where T
```

```@docs
direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T
direct_product(M::ModuleFP{T}, Ms::ModuleFP{T}...; task::Symbol = :prod) where T
```

## Truncation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,12 @@ function tensor_product(factors::Vector{<:AbsHyperComplex})
return HCTensorProductComplex(factors)
end

function tensor_product(c::AbsHyperComplex...)
return tensor_product(collect(c))
function tensor_product(c::AbsHyperComplex, cs::AbsHyperComplex...)
return tensor_product([c, cs...])
end

function tensor_product(M::ModuleFP{T}...) where {U<:MPolyComplementOfPrimeIdeal, T<:MPolyLocRingElem{<:Any, <:Any, <:Any, <:Any, U}}
R = base_ring(first(M))
@assert all(N->base_ring(N)===R, M) "modules must be defined over the same ring"
return tensor_product([free_resolution(SimpleFreeResolution, N)[1] for N in M]...)
function tensor_product(M::ModuleFP{T}, Ms::ModuleFP{T}...) where {U<:MPolyComplementOfPrimeIdeal, T<:MPolyLocRingElem{<:Any, <:Any, <:Any, <:Any, U}}
R = base_ring(M)
@assert all(N->base_ring(N)===R, Ms) "modules must be defined over the same ring"
return tensor_product([free_resolution(SimpleFreeResolution, N)[1] for N in (M, Ms...)])
end


10 changes: 8 additions & 2 deletions experimental/GModule/src/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ function Oscar.tensor_product(C::GModule{<:Any, FinGenAbGroup}...; task::Symbol
end
end

function Oscar.tensor_product(C::GModule{S, <:AbstractAlgebra.FPModule{<:Any}}...; task::Symbol = :map) where S <: Oscar.GAPGroup
function Oscar.tensor_product(C::U, Cs::U...; task::Symbol = :map) where {S <: Oscar.GAPGroup, U <: GModule{S, <:AbstractAlgebra.FPModule{<:Any}}}
return Oscar.tensor_product([C, Cs...]; task)
end
function Oscar.tensor_product(C::Vector{U}; task::Symbol = :map) where {S <: Oscar.GAPGroup, U <: GModule{S, <:AbstractAlgebra.FPModule{<:Any}}}
@assert all(x->x.G == C[1].G, C)
@assert all(x->base_ring(x) == base_ring(C[1]), C)

Expand All @@ -463,7 +466,10 @@ import Hecke.⊗
⊗(C::GModule...) = Oscar.tensor_product(C...; task = :none)


function Oscar.tensor_product(F::AbstractAlgebra.FPModule{T}...; task = :none) where {T}
function Oscar.tensor_product(F::AbstractAlgebra.FPModule{T}, Fs::AbstractAlgebra.FPModule{T}...; task = :none) where {T}
return Oscar.tensor_product([F, Fs...]; task)
end
function Oscar.tensor_product(F::Vector{<:AbstractAlgebra.FPModule{T}}; task = :none) where {T}
@assert all(x->base_ring(x) == base_ring(F[1]), F)
d = prod(dim(x) for x = F)
G = free_module(base_ring(F[1]), d)
Expand Down
16 changes: 13 additions & 3 deletions src/Modules/UngradedModules/DirectSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Additionally, return
- two vectors containing the canonical projections and injections, respectively, if `task = :both`,
- none of the above maps if `task = :none`.
"""
function direct_product(F::FreeMod{T}...; task::Symbol = :prod) where {T}
function direct_product(M::FreeMod{T}, Ms::FreeMod{T}...; task::Symbol = :prod) where T
return direct_product([M, Ms...]; task)
end
function direct_product(F::Vector{<:FreeMod{T}}; task::Symbol = :prod) where T
R = base_ring(F[1])
G = FreeMod(R, sum([rank(f) for f = F]))
all_graded = all(is_graded, F)
Expand Down Expand Up @@ -70,7 +73,10 @@ Additionally, return
- two vectors containing the canonical projections and injections, respectively, if `task = :both`,
- none of the above maps if `task = :none`.
"""
function direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T
function direct_product(M::ModuleFP{T}, Ms::ModuleFP{T}...; task::Symbol = :prod) where T
return direct_product([M, Ms...]; task)
end
function direct_product(M::Vector{<:ModuleFP{T}}; task::Symbol = :prod) where T
F, pro, mF = direct_product([ambient_free_module(x) for x = M]..., task = :both)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
F, pro, mF = direct_product([ambient_free_module(x) for x = M]..., task = :both)
F, pro, mF = direct_product([ambient_free_module(x) for x = M], task = :both)

Better to not splat here, but use the new method taking a vector

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this is indeed now available in all possible cases that could occur here.

s, emb_sF = sub(F, vcat([elem_type(F)[mF[i](y) for y = ambient_representatives_generators(M[i])] for i=1:length(M)]...))
q::Vector{elem_type(F)} = vcat([elem_type(F)[mF[i](y) for y = rels(M[i])] for i=1:length(M)]...)
Expand Down Expand Up @@ -127,6 +133,7 @@ function direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T
end
end
end

##################################################
# direct sum
##################################################
Expand All @@ -141,7 +148,10 @@ Additionally, return
- two vectors containing the canonical injections and projections, respectively, if `task = :both`,
- none of the above maps if `task = :none`.
"""
function direct_sum(M::ModuleFP{T}...; task::Symbol = :sum) where {T}
function direct_sum(M::ModuleFP{T}, Ms::ModuleFP{T}...; task::Symbol = :prod) where T
return direct_sum([M, Ms...]; task)
end
function direct_sum(M::Vector{<:ModuleFP{T}}; task::Symbol = :prod) where T
joschmitt marked this conversation as resolved.
Show resolved Hide resolved
res = direct_product(M...; task)
if task == :sum || task == :prod
ds, f = res
Expand Down
2 changes: 0 additions & 2 deletions test/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ using Aqua
Aqua.test_all(
Oscar;
ambiguities=false, # TODO: fix ambiguities
unbound_args=false, # TODO: fix unbound type parameters
piracies=false, # TODO: check the reported methods to be moved upstream
# Aqua persistent task does not work properly with developed dependencies
# thus we disable these tests when running in OscarCI:
persistent_tasks=!haskey(ENV, "oscar_run_tests"),
)
@test length(Aqua.detect_unbound_args_recursively(Oscar)) <= 16
end
Loading