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

For Modules over PBWAlgRing and PBWAlgQuo #3900

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions src/Modules/ModuleTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Moreover, canonical incoming and outgoing morphisms are stored if the correspond
option is set in suitable functions.
`FreeMod{T}` is a subtype of `AbstractFreeMod{T}`.
"""
@attributes mutable struct FreeMod{T <: RingElem} <: AbstractFreeMod{T}
R::Ring
@attributes mutable struct FreeMod{T <: Union{RingElem, PBWAlgElem, PBWAlgQuoElem}} <: AbstractFreeMod{T}
R::Union{Ring,PBWAlgRing,PBWAlgQuo}
n::Int
S::Vector{Symbol}
d::Union{Vector{FinGenAbGroupElem}, Nothing}
Expand All @@ -91,7 +91,7 @@ option is set in suitable functions.
incoming::WeakKeyIdDict{<:ModuleFP, <:Tuple{<:SMat, <:Any}}
outgoing::WeakKeyIdDict{<:ModuleFP, <:Tuple{<:SMat, <:Any}}

function FreeMod{T}(n::Int,R::Ring,S::Vector{Symbol}) where T <: RingElem
function FreeMod{T}(n::Int,R::Union{Ring, PBWAlgQuo, PBWAlgRing},S::Vector{Symbol}) where T <: Union{RingElem, PBWAlgElem, PBWAlgQuoElem}
r = new{elem_type(R)}()
r.n = n
r.R = R
Expand Down
18 changes: 18 additions & 0 deletions src/Modules/UngradedModules/FreeMod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ function FreeMod(R::Ring, names::Vector{Symbol}; cached::Bool=false)
return FreeMod{elem_type(R)}(length(names), R, names)
end

function FreeMod(R::PBWAlgQuo, n::Int, name::VarName = :e; cached::Bool = false) # TODO cached?
return FreeMod{elem_type(R)}(n, R, [Symbol("$name[$i]") for i=1:n])
end

function FreeMod(R::PBWAlgRing, n::Int, name::VarName = :e; cached::Bool = false) # TODO cached?
return FreeMod{elem_type(R)}(n, R, [Symbol("$name[$i]") for i=1:n])
end

function FreeMod(R::PBWAlgQuo, names::Vector{String}; cached::Bool=false)
Lax202 marked this conversation as resolved.
Show resolved Hide resolved
return FreeMod{elem_type(R)}(length(names), R, Symbol.(names))
end

function FreeMod(R::PBWAlgRing, names::Vector{String}; cached::Bool=false)
Lax202 marked this conversation as resolved.
Show resolved Hide resolved
return FreeMod{elem_type(R)}(length(names), R, Symbol.(names))
end

@doc raw"""
free_module(R::MPolyRing, p::Int, name::VarName = :e; cached::Bool = false)
free_module(R::MPolyQuoRing, p::Int, name::VarName = :e; cached::Bool = false)
Expand Down Expand Up @@ -75,6 +91,8 @@ free_module(R::MPolyRing, p::Int, name::VarName = :e; cached::Bool = false) = Fr
free_module(R::MPolyQuoRing, p::Int, name::VarName = :e; cached::Bool = false) = FreeMod(R, p, name, cached = cached)
free_module(R::MPolyLocRing, p::Int, name::VarName = :e; cached::Bool = false) = FreeMod(R, p, name, cached = cached)
free_module(R::MPolyQuoLocRing, p::Int, name::VarName = :e; cached::Bool = false) = FreeMod(R, p, name, cached = cached)
free_module(R::PBWAlgQuo, p::Int, name::VarName = :e; cached::Bool = false) = FreeMod(R,p,name,cached = cached)
free_module(R::PBWAlgRing, p::Int, name::VarName = :e; cached::Bool = false) = FreeMod(R,p,name,cached = cached)

#=XXX this cannot be as it is inherently ambiguous
- FreeModule(R, n)
Expand Down
2 changes: 2 additions & 0 deletions src/Modules/UngradedModules/FreeModElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ end
*(a::Int, b::AbstractFreeModElem) = parent(b)(a*coordinates(b))
*(a::Integer, b::AbstractFreeModElem) = parent(b)(base_ring(parent(b))(a)*coordinates(b))
*(a::QQFieldElem, b::AbstractFreeModElem) = parent(b)(base_ring(parent(b))(a)*coordinates(b))
*(a::PBWAlgQuoElem, b::AbstractFreeModElem) = parent(b)(a*coordinates(b))
*(a::PBWAlgElem, b::AbstractFreeModElem) = parent(b)(a*coordinates(b))

@doc raw"""
zero(F::AbstractFreeMod)
Expand Down
61 changes: 61 additions & 0 deletions test/Modules/PBWModules.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@testset "modules over PBWAlgQuo" begin
#Free Module tests
E,x = exterior_algebra(QQ, 3)
Copy link
Member

Choose a reason for hiding this comment

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

This function is part of experimental and should thus not be used in the tests for src/ code

Copy link
Member

Choose a reason for hiding this comment

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

True. Though maybe we need to look into promoting exterior_algebra one of these days?

In any case, note that this PR is still a very early draft, I mainly asked @Lax202 to open it so we can better see what she's doing and what the state is, and then discuss it. The code still needs to be consolidated into a new source file, and that may very well ultimately end up in the experimental tree. We'll see.

Copy link
Member

Choose a reason for hiding this comment

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

In the meantime this was merged as part of PR #3988 which copied the tests from here. If we still don't want the exterior_algebra call here, then someone else should remove it from there.

M = free_module(E, 3)
@test ngens(M) == 3
@test gens(M)[1] in M
@test parent(M[1]) == M
v = [x[1], x[1] + x[2], x[1]*x[2]]
@test v == Vector(M(v))

#SubModuleOfFreeModule tests
N = Oscar.SubModuleOfFreeModule(M, gens(M)[1:2])
@test gens(N) == gens(M)[1:2]
@test N[1] in M
#fails! #NEEDS A 'DEFAULT ORDERING' on the PBWAlgQuo ie on E
#@test M(v) in N

#FreeModuleHom tests
W = free_module(E,2)
G = hom(W,M, gens(M)[1:2])
@test ngens(image(G)[1]) == 2

#SubQuoModule tests
Q1 = SubquoModule(M, [x[1]*M[1]])
Q2 = SubquoModule(M, [x[2]*M[1]])
#fail! #NEEDS A 'DEFAULT ORDERING' on the PBWAlgQuo ie on E
#@test !is_canonically_isomorphic(Q2,Q1)
#simplify(Q[1])
end

@testset "modules over PBWAlgRing" begin
R, (x, y, z) = QQ["x", "y", "z"]
L = [x*y, x*z, y*z + 1]
REL = strictly_upper_triangular_matrix(L)
A, (x, y, z) = pbw_algebra(R, REL, deglex(gens(R)))
M = free_module(A, 3)
@test ngens(M) == 3
@test gens(M)[1] in M
@test parent(M[1]) == M
v = [x, x+y, x*y]
@test v == Vector(M(v))

#SubModuleOfFreeModule tests
N = Oscar.SubModuleOfFreeModule(M, gens(M)[1:2])
@test gens(N) == gens(M)[1:2]
@test N[1] in M
#fails! #NEEDS A 'DEFAULT ORDERING' on the PBWAlgQuo ie on E
#@test M(v) in N

#FreeModuleHom tests
W = free_module(A,2)
G = hom(W,M, gens(M)[1:2])
@test ngens(image(G)[1]) == 2

#SubQuoModule tests
Q1 = SubquoModule(M, [x*M[1]])
Q2 = SubquoModule(M, [y*M[1]])
#fail! #NEEDS A 'DEFAULT ORDERING' on the PBWAlgQuo ie on E
#@test !is_canonically_isomorphic(Q2,Q1)
#simplify(Q[1])
end
Loading