Skip to content

Commit

Permalink
RFC: Add function to obtain underlying abelian group
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Jul 15, 2021
1 parent fa25f4d commit 9b14618
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 deletions.
19 changes: 9 additions & 10 deletions src/Modules/FreeModules-graded.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#TODO make d and S a function optionally - to support HUGE degree
export presentation, decoration
export presentation, grading_group

abstract type ModuleFP_dec{T} end

Expand Down Expand Up @@ -29,7 +29,7 @@ mutable struct FreeModule_dec{T} <: ModuleFP_dec{T}
end

function FreeModule(R::Ring_dec, n::Int, name::String = "e"; cached::Bool = false)
return FreeModule_dec([decoration(R)[0] for i=1:n], R, [Symbol("$name[$i]") for i=1:n])
return FreeModule_dec([grading_group(R)[0] for i=1:n], R, [Symbol("$name[$i]") for i=1:n])
end
free_module(R::Ring_dec, n::Int, name::String = "e"; cached::Bool = false) = FreeModule(R, n, name, cached = cached)

Expand Down Expand Up @@ -686,7 +686,7 @@ function syzygie_module(F::BiModArray; sub = 0)
G = sub
else
[F[Val(:O), i] for i = 1:length(F.O)]
z = decoration(base_ring(F.F))[0]
z = grading_group(base_ring(F.F))[0]
G = FreeModule(base_ring(F.F), [iszero(x) ? z : degree(x) for x = F.O])
end
return SubQuo_dec(G, s)
Expand Down Expand Up @@ -729,9 +729,8 @@ function *(a::FreeModuleElem_dec, b::Array{FreeModuleElem_dec, 1})
return s
end

decoration(F::FreeModule_dec) = decoration(F.R)
decoration(R::MPolyRing_dec) = R.D
decoration(SQ::SubQuo_dec) = decoration(SQ.F)
grading_group(F::FreeModule_dec) = grading_group(F.R)
grading_group(SQ::SubQuo_dec) = grading_group(SQ.F)

function presentation(SQ::SubQuo_dec)
#A+B/B is generated by A and B
Expand Down Expand Up @@ -762,7 +761,7 @@ function presentation(SQ::SubQuo_dec)
push!(w, degree(q[end]))
end
#want R^a -> R^b -> SQ -> 0
#TODO sort decoration and fix maps, same decoration should be bundled (to match pretty printing)
#TODO sort grading_group and fix maps, same grading_group should be bundled (to match pretty printing)
G = FreeModule(R, w)
h_G_F = hom(G, F, q)
@assert iszero(h_G_F) || iszero(degree(h_G_F))
Expand Down Expand Up @@ -1054,7 +1053,7 @@ end
function free_resolution(S::SubQuo_dec, limit::Int = -1)
p = presentation(S)
mp = [map(p, j) for j=1:length(p)]
D = decoration(S)
D = grading_group(S)
while true
k, mk = kernel(mp[1])
nz = findall(x->!iszero(x), gens(k))
Expand Down Expand Up @@ -1109,7 +1108,7 @@ function hom(M::ModuleFP_dec, N::ModuleFP_dec)
#Janko: have R^t1 -- g1 = map(p2, 0) -> R^t0 -> G
#kernel g1: k -> R^t1
#source: Janko's CA script: https://www.mathematik.uni-kl.de/~boehm/lehre/17_CA/ca.pdf
D = decoration(M)
D = grading_group(M)
F = FreeModule(base_ring(M), GrpAbFinGenElem[iszero(x) ? D[0] : degree(x) for x = gens(k)])
g2 = hom(F, codomain(mk), collect(k.sub)) #not clean - but maps not (yet) working
#step 2
Expand Down Expand Up @@ -1364,7 +1363,7 @@ function homogeneous_component(F::T, d::GrpAbFinGenElem) where {T <: Union{FreeM
#TODO: lazy: ie. no enumeration of points
# aparently it is possible to get the number of points faster than the points
W = base_ring(F)
D = decoration(W)
D = grading_group(W)
#have gens for W that can be combined
# F that can only be used
#F ni f = sum c_i,j F[i]*w[j]
Expand Down
12 changes: 10 additions & 2 deletions src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,14 @@ end
#
################################################################################

function grading(R::MPolyQuo)
if R.R isa MPolyRing_dec
return grading(R.R)
else
error("Underlying polynomialring must be graded")
end
end

function degree(a::MPolyQuoElem{<:MPolyElem_dec})
simplify!(a)
@req !iszero(a) "Element must be non-zero"
Expand All @@ -883,7 +891,7 @@ function ishomogeneous(a::MPolyQuoElem{<:MPolyElem_dec})
return ishomogeneous(a.f)
end

decoration(q::MPolyQuo{<:MPolyElem_dec}) = decoration(q.R)
grading_group(q::MPolyQuo{<:MPolyElem_dec}) = grading_group(q.R)

function hash(w::MPolyQuoElem, u::UInt)
simplify!(w)
Expand All @@ -894,7 +902,7 @@ function homogeneous_component(W::MPolyQuo{<:MPolyElem_dec}, d::GrpAbFinGenElem)
#TODO: lazy: ie. no enumeration of points
# aparently it is possible to get the number of points faster than the points
D = parent(d)
@assert D == decoration(W)
@assert D == grading_group(W)
R = base_ring(W)
I = modulus(W)

Expand Down
4 changes: 3 additions & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export weight, decorate, ishomogeneous, homogeneous_components, filtrate,
grade, GradedPolynomialRing, homogeneous_component, jacobi_matrix, jacobi_ideal,
HilbertData, hilbert_series, hilbert_series_reduced, hilbert_series_expanded, hilbert_function, hilbert_polynomial,
HilbertData, hilbert_series, hilbert_series_reduced, hilbert_series_expanded, hilbert_function, hilbert_polynomial, grading,
homogenization, dehomogenization
export MPolyRing_dec, MPolyElem_dec
mutable struct MPolyRing_dec{T, S} <: AbstractAlgebra.MPolyRing{T}
Expand All @@ -26,6 +26,8 @@ mutable struct MPolyRing_dec{T, S} <: AbstractAlgebra.MPolyRing{T}
end
end

grading_group(W::MPolyRing_dec) = W.D

isgraded(W::MPolyRing_dec) = !isdefined(W, :lt)
isfiltered(W::MPolyRing_dec) = isdefined(W, :lt)

Expand Down
2 changes: 1 addition & 1 deletion test/Modules/FreeModules-graded-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
@test Oscar.isgraded(F) == Oscar.isgraded(RR)
@test Oscar.isfiltered(F) == Oscar.isfiltered(RR)

G = decoration(F)
G = grading_group(F)
if j == 4
a = G([convert(fmpz,x) for x = [1,0,1]])
else
Expand Down
2 changes: 1 addition & 1 deletion test/Modules/GradedModules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

free_resolution(H)

homogeneous_component(H, Oscar.decoration(F)[0])
homogeneous_component(H, grading_group(F)[0])
end

@testset "Graded Modules 2" begin
Expand Down
10 changes: 8 additions & 2 deletions test/Rings/mpoly-graded-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function _homogeneous_polys(polys::Vector{<:MPolyElem})
_monomials = append!(_monomials, monomials(polys[i]))
end
hom_polys = []
for deg in unique([iszero(mon) ? id(decoration(R)) : degree(mon) for mon = _monomials])
for deg in unique([iszero(mon) ? id(grading_group(R)) : degree(mon) for mon = _monomials])
g = zero(R)
for i = 1:4
if haskey(D[i], deg)
Expand Down Expand Up @@ -139,7 +139,7 @@ end
@test Oscar.isfiltered(R_quo) == Oscar.isfiltered(RR)
@test Oscar.isgraded(R_quo) == Oscar.isgraded(RR)

@test decoration(R_quo) == decoration(RR)
@test grading_group(R_quo) == grading_group(RR)

d_Elem = d_Elems[RR]

Expand Down Expand Up @@ -186,3 +186,9 @@ end
R, (x,y) = grade(PolynomialRing(QQ, ["x", "y"])[1]);
@test_throws ArgumentError degree(zero(R))
end

@testset "Grading" begin
R, (x,y) = grade(PolynomialRing(QQ, ["x", "y"])[1]);
D = grading_group(R)
@test isisomorphic(D, abelian_group([0]))
end

0 comments on commit 9b14618

Please sign in to comment.