Skip to content

Commit

Permalink
Change DeformationMap type param
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 1, 2024
1 parent 1d169c7 commit c45e9c7
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 111 deletions.
38 changes: 19 additions & 19 deletions src/DeformationBases/ArcDiagDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ Each element of the basis is induced by an arc diagram of a suitable size,
which gets symmetrized and specialised to the given smash product.
This process is due to [FM22](@cite).
"""
struct ArcDiagDeformBasis{C <: RingElem} <: DeformBasis{C}
struct ArcDiagDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{C}, Set{ArcDiagram}}
extra_data::Dict{DeformationMap{T}, Set{ArcDiagram}}
normalize

function ArcDiagDeformBasis{C}(
sp::SmashProductLie{C},
function ArcDiagDeformBasis{T}(
sp::SmashProductLie{C, LieC, LieT},
degs::AbstractVector{Int};
no_normalize::Bool=false,
) where {C <: RingElem}
T = get_attribute(base_lie_algebra(sp), :type, nothing)::Union{Nothing,Symbol}
@req T in [:special_orthogonal, :general_linear] "Only works for so_n and gl_n."
if T == :special_orthogonal && has_attribute(base_lie_algebra(sp), :form)
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: SmashProductLieElem{C, LieC, LieT}}
LieType = get_attribute(base_lie_algebra(sp), :type, nothing)::Union{Nothing,Symbol}
@req LieType in [:special_orthogonal, :general_linear] "Only works for so_n and gl_n."
if LieType == :special_orthogonal && has_attribute(base_lie_algebra(sp), :form)
@req isone(get_attribute(base_lie_algebra(sp), :form)::dense_matrix_type(C)) "Only works for so_n represented as skew-symmetric matrices."
end
return ArcDiagDeformBasis{C}(Val(T), sp, degs; no_normalize)
return ArcDiagDeformBasis{T}(Val(LieType), sp, degs; no_normalize)
end

function ArcDiagDeformBasis{C}(
T::Union{SO, GL},
sp::SmashProductLie{C},
function ArcDiagDeformBasis{T}(
LieType::Union{SO, GL},
sp::SmashProductLie{C, LieC, LieT},
degs::AbstractVector{Int};
no_normalize::Bool=false,
) where {C <: RingElem}
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: SmashProductLieElem{C, LieC, LieT}}
V = base_module(sp)

V_nice, h = isomorphic_module_with_simple_structure(V)
Expand All @@ -43,7 +43,7 @@ struct ArcDiagDeformBasis{C <: RingElem} <: DeformBasis{C}
V_nice = temp
end

extra_data = Dict{DeformationMap{C}, Set{ArcDiagram}}()
extra_data = Dict{DeformationMap{T}, Set{ArcDiagram}}()
normalize = no_normalize ? identity : normalize_default

n_cases = div(length(V_nice_summands) * (length(V_nice_summands) + 1), 2)
Expand All @@ -69,12 +69,12 @@ struct ArcDiagDeformBasis{C <: RingElem} <: DeformBasis{C}
tensor_product(V_nice_summand_i_l, V_nice_summand_i_r)
end

diag_iter = pbw_arc_diagrams(T, W, d)
diag_iter = pbw_arc_diagrams(LieType, W, d)
len = length(diag_iter)
iter = (
begin
@vprintln :PBWDeformations 2 "Basis generation deg $(lpad(d, maximum(ndigits, degs))), case $(lpad(case, ndigits(n_cases)))/$(n_cases), $(lpad(floor(Int, 100*counter / len), 3))%, $(lpad(counter, ndigits(len)))/$(len)"
_basis_elem = arcdiag_to_deformationmap(T, diag, sp, W)
_basis_elem = arcdiag_to_deformationmap(LieType, diag, sp, W)
basis_elem = matrix(proj_to_summand_l) * _basis_elem * transpose(matrix(proj_to_summand_r))
if i_l != i_r
basis_elem -= transpose(basis_elem)
Expand Down Expand Up @@ -103,13 +103,13 @@ struct ArcDiagDeformBasis{C <: RingElem} <: DeformBasis{C}
iter = Iterators.flatten(iters)
if !no_normalize
iter = unique(Iterators.filter(b -> !iszero(b), iter))
collected = Vector{DeformationMap{C}}(collect(iter))::Vector{DeformationMap{C}}
collected = Vector{DeformationMap{T}}(collect(iter))::Vector{DeformationMap{T}}
_, rels = is_linearly_independent_with_relations(coefficient_ring(sp), collected)
inds = [findlast(!iszero, vec(rels[i, :]))::Int for i in 1:nrows(rels)]
deleteat!(collected, inds)
return new{C}(length(collected), collected, extra_data, normalize)
return new{T}(length(collected), collected, extra_data, normalize)
end
return new{C}(len, iter, extra_data, normalize)
return new{T}(len, iter, extra_data, normalize)
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/DeformationBases/DeformBasis.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Base.eltype(::Type{<:DeformBasis{C}}) where {C <: RingElem} = DeformationMap{C}
Base.eltype(::Type{<:DeformBasis{T}}) where {T <: SmashProductLieElem} = DeformationMap{T}

Base.length(basis::DeformBasis) = error("length not implemented for $(typeof(basis))")


"""
lookup_data(m::DeformationMap{C}, basis::DeformBasis{C}) where {C <: RingElem}
lookup_data(m::DeformationMap{T}, basis::DeformBasis{T}) where {T <: SmashProductLieElem}
Look up additional data that was used to generate the deformation map `m` in the basis `basis`.
This can e.g. be an arc diagram or a pseudograph.
"""
function lookup_data(m::DeformationMap{C}, basis::DeformBasis{C}) where {C <: RingElem}
function lookup_data(m::DeformationMap{T}, basis::DeformBasis{T}) where {T <: SmashProductLieElem}
m = basis.normalize(m)
if haskey(basis.extra_data, m)
return basis.extra_data[m]
Expand All @@ -18,7 +18,7 @@ function lookup_data(m::DeformationMap{C}, basis::DeformBasis{C}) where {C <: Ri
end
end

function normalize_default(m::DeformationMap{C}) where {C <: RingElem}
function normalize_default(m::DeformationMap{T}) where {T <: SmashProductLieElem}
nz_index = findfirst(x -> !iszero(x), m)
if nz_index === nothing
return m
Expand Down
30 changes: 15 additions & 15 deletions src/DeformationBases/PseudographDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ certain properties, which gets transformed to an arc diagram and then handled as
in [`ArcDiagDeformBasis`](@ref).
This process is due to [FM22](@cite).
"""
struct PseudographDeformBasis{C <: RingElem} <: DeformBasis{C}
struct PseudographDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{C}, Set{Tuple{PseudographLabelled{Int}, Partition{Int}}}}
extra_data::Dict{DeformationMap{T}, Set{Tuple{PseudographLabelled{Int}, Partition{Int}}}}
normalize

function PseudographDeformBasis{C}(
sp::SmashProductLie{C},
function PseudographDeformBasis{T}(
sp::SmashProductLie{C, LieC, LieT},
degs::AbstractVector{Int};
no_normalize::Bool=false,
) where {C <: RingElem}
T = get_attribute(base_lie_algebra(sp), :type, nothing)
@req T == :special_orthogonal "Only works for so_n."
if T == :special_orthogonal && has_attribute(base_lie_algebra(sp), :form)
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: SmashProductLieElem{C, LieC, LieT}}
LieType = get_attribute(base_lie_algebra(sp), :type, nothing)
@req LieType == :special_orthogonal "Only works for so_n."
if LieType == :special_orthogonal && has_attribute(base_lie_algebra(sp), :form)
@req isone(get_attribute(base_lie_algebra(sp), :form)) "Only works for so_n represented as skew-symmetric matrices."
end
return PseudographDeformBasis{C}(Val(T), sp, degs; no_normalize)
return PseudographDeformBasis{T}(Val(LieType), sp, degs; no_normalize)
end

function PseudographDeformBasis{C}(
T::Union{Val{:special_orthogonal}},
sp::SmashProductLie{C},
function PseudographDeformBasis{T}(
LieType::Union{Val{:special_orthogonal}},
sp::SmashProductLie{C, LieC, LieT},
degs::AbstractVector{Int};
no_normalize::Bool=false,
) where {C <: RingElem}
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: SmashProductLieElem{C, LieC, LieT}}
fl, Vbase, e = _is_exterior_power(base_module(sp))
@req fl && _is_standard_module(Vbase) "Only works for exterior powers of the standard module."

Expand All @@ -46,7 +46,7 @@ struct PseudographDeformBasis{C <: RingElem} <: DeformBasis{C}
begin
@vprintln :PBWDeformations 2 "Basis generation deg $(lpad(d, maximum(ndigits, degs))), $(lpad(floor(Int, 100*(debug_counter = (debug_counter % len) + 1) / len), 3))%, $(lpad(debug_counter, ndigits(len)))/$(len)"
diag = to_arcdiag(pg, part)
basis_elem = arcdiag_to_deformationmap(T, diag, sp)
basis_elem = arcdiag_to_deformationmap(LieType, diag, sp)
if !no_normalize
basis_elem = normalize(basis_elem)
end
Expand All @@ -65,7 +65,7 @@ struct PseudographDeformBasis{C <: RingElem} <: DeformBasis{C}
iter = Iterators.flatten(iters)
if !no_normalize
iter = unique(Iterators.filter(b -> !iszero(b), iter))
collected = Vector{DeformationMap{C}}(collect(iter))
collected = Vector{DeformationMap{T}}(collect(iter))::Vector{DeformationMap{T}}
_, rels = is_linearly_independent_with_relations(coefficient_ring(sp), reverse(collected))
inds = [1 + ncols(rels) - (findfirst(!iszero, vec(rels[i, :]))::Int) for i in nrows(rels):-1:1]
deleteat!(collected, inds)
Expand Down
11 changes: 7 additions & 4 deletions src/DeformationBases/StdDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Each element of the basis is a skew-symmetric matrix with 2 non-zero entries,
where one entry is a pure tensor power of degree ∈ `degs` over the Lie algebra part
of the smash product, and the other entry is its additive inverse.
"""
struct StdDeformBasis{C <: RingElem} <: DeformBasis{C}
struct StdDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{C}, Nothing}
extra_data::Dict{DeformationMap{T}, Nothing}
normalize

function StdDeformBasis{C}(sp::SmashProductLie{C}, degs::AbstractVector{Int}) where {C <: RingElem}
function StdDeformBasis{T}(
sp::SmashProductLie{C, LieC, LieT},
degs::AbstractVector{Int}
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: SmashProductLieElem{C, LieC, LieT}}
dimL = dim(base_lie_algebra(sp))
dimV = dim(base_module(sp))
iter = (
Expand All @@ -24,7 +27,7 @@ struct StdDeformBasis{C <: RingElem} <: DeformBasis{C}
)

len = div(dimV * (dimV - 1), 2) * sum(binomial(dimL + k - 1, k) for k in degs)
return new{C}(len, iter, Dict{DeformationMap{C}, Nothing}(), normalize_default)
return new{T}(len, iter, Dict{DeformationMap{T}, Nothing}(), normalize_default)
end
end

Expand Down
18 changes: 9 additions & 9 deletions src/SmashProductLieDeform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,35 +257,36 @@ end
###############################################################################

"""
deform(sp::SmashProductLie{C}, kappa::DeformationMap{C}) where {C <: RingElem}
deform(sp::SmashProductLie{C}, kappa::DeformationMap{elem_type(sp)}) where {C <: RingElem}
Constructs the deformation of the smash product `sp` by the deformation map `kappa`.
Returns a [`SmashProductLieDeform`](@ref) struct and a two-part basis.
"""
function deform(
sp::SmashProductLie{C, LieC, LieT},
kappa::DeformationMap{C},
kappa::DeformationMap{SmashProductLieElem{C, LieC, LieT}},
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}}
dimL = dim(base_lie_algebra(sp))
dimV = dim(base_module(sp))

@req size(kappa) == (dimV, dimV) "kappa has wrong dimensions."
@req all(e -> parent(e) == sp, kappa) "Incompatible smash products."

basisV = [gen(underlying_algebra(sp), dimL + i) for i in 1:dimV]

for i in 1:dimV, j in 1:i
@req kappa[i, j] == -kappa[j, i] "kappa is not skew-symmetric."
@req all(x -> x <= dimL, Iterators.flatten(exponent_words(kappa[i, j]))) "kappa does not only take values in the hopf algebra"
@req all(x -> x <= dimL, Iterators.flatten(exponent_words(kappa[j, i]))) "kappa does not only take values in the hopf algebra"
@req all(<=(dimL), Iterators.flatten(exponent_words(kappa[i, j].alg_elem))) "kappa does not only take values in the hopf algebra"
@req all(<=(dimL), Iterators.flatten(exponent_words(kappa[j, i].alg_elem))) "kappa does not only take values in the hopf algebra"
end

symmetric = true
rels = deepcopy(sp.rels)
for i in 1:dimV, j in 1:dimV
# We have the commutator relation [v_i, v_j] = kappa[i,j]
# which is equivalent to v_i*v_j = v_j*v_i + kappa[i,j]
rels[dimL+i, dimL+j] = basisV[j] * basisV[i] + kappa[i, j]
rels[dimL+i, dimL+j] = basisV[j] * basisV[i] + simplify(kappa[i, j]).alg_elem
symmetric &= iszero(kappa[i, j])
end

Expand All @@ -298,10 +299,9 @@ end

function deform(
sp::SmashProductLie{C, LieC, LieT},
kappa::MatElem{SmashProductLieElem{C, LieC, LieT}},
kappa::MatElem{<:FreeAssAlgElem{C}},
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}}
@req all(x -> parent(x) == sp, kappa) "Incompatible smash products."
return deform(sp, map_entries(x -> x.alg_elem, kappa))
return deform(sp, map_entries(sp, kappa))
end

"""
Expand All @@ -312,7 +312,7 @@ Constructs the symmetric deformation of the smash product `sp`.
function symmetric_deformation(
sp::SmashProductLie{C, LieC, LieT},
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}}
kappa = zero_matrix(underlying_algebra(sp), dim(base_module(sp)), dim(base_module(sp)))
kappa = zero_matrix(sp, dim(base_module(sp)), dim(base_module(sp)))
d = deform(sp, kappa)
return d
end
10 changes: 5 additions & 5 deletions src/SmashProductPBWDeformLie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end


"""
all_pbwdeformations(sp::SmashProductLie{C}, deform_basis::DeformBasis{C}; special_return=Nothing) where {C <: RingElem}
all_pbwdeformations(sp::SmashProductLie{C}, deform_basis::DeformBasis{elem_type(sp)}; special_return=Nothing) where {C <: RingElem}
Computes a basis of all Poincare-Birkhoff-Witt deformations of `sp`.
`deform_basis` specifies the basis to use for the space of deformation maps.
Expand All @@ -99,10 +99,10 @@ If `special_return` is `SMat`, the function returns intermediate results.
Uses [`pbwdeform_eqs`](@ref) and thus Theorem 3.1 of [WW14](@cite).
"""
function all_pbwdeformations(
sp::SmashProductLie{C},
deform_basis::DeformBasis{C};
sp::SmashProductLie{C, LieC, LieT},
deform_basis::DeformBasis{SmashProductLieElem{C, LieC, LieT}};
special_return::Type{T}=Nothing,
) where {C <: RingElem, T <: Union{Nothing, SMat}}
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}, T <: Union{Nothing, SMat}}
@req coefficient_ring(sp) == QQ "Only implemented for QQ coefficients."

dimL = dim(base_lie_algebra(sp))
Expand Down Expand Up @@ -157,7 +157,7 @@ function all_pbwdeformations(
end

@vprintln :PBWDeformations 1 "Computing a basis..."
kappas = Vector{DeformationMap{C}}(undef, ker_dim)
kappas = Vector{DeformationMap{elem_type(sp)}}(undef, ker_dim)
for l in 1:ker_dim
kappa = zero_matrix(underlying_algebra(sp), dimV, dimV)
for (i, b) in enumerate(deform_basis)
Expand Down
60 changes: 30 additions & 30 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,34 +211,6 @@ struct PseudographLabelled{T}
end
end

################################################################################
#
# Deformation maps
#
################################################################################

"""
DeformationMap{C} = MatElem{FreeAssAlgElem{C}} where {C <: RingElem}
The type for deformation maps of a Lie algebra smash product.
The entry `kappa[i,j]` should be the image of ``v_i \\wedge v_j`` under the deformation map, i.e. ``κ(v_i,v_j)``.
Deformation maps are always assumed to be quadratic and skew-symmetric.
"""
const DeformationMap{C} = MatElem{<:FreeAssAlgElem{C}} where {C <: RingElem} # TODO: make concrete type


"""
abstract type DeformBasis{C <: RingElem} end
A basis for a deformation map space of a Lie algebra smash product.
The constructor of a subtype should accept a [`SmashProductLie`](@ref) and an `AbstractVector{Int}` of degrees.
It is required that `Base.length` and `Base.iterate` are implemented for subtypes,
where iterating yields objects of type `DeformationMap{C}`.
For a reference implementation, we refer to [`StdDeformBasis`](@ref).
"""
abstract type DeformBasis{C <: RingElem} end

################################################################################
#
# Smash products
Expand Down Expand Up @@ -284,6 +256,34 @@ mutable struct SmashProductLieElem{C <: RingElem, LieC <: FieldElem, LieT <: Lie
end
end

################################################################################
#
# Deformation maps
#
################################################################################

"""
DeformationMap{T} = MatElem{T} where {T <: SmashProductLieElem}
The type for deformation maps of a Lie algebra smash product.
The entry `kappa[i,j]` should be the image of ``v_i \\wedge v_j`` under the deformation map, i.e. ``κ(v_i,v_j)``.
Deformation maps are always assumed to be quadratic and skew-symmetric.
"""
const DeformationMap{T} = MatElem{T} where {T <: SmashProductLieElem} # TODO: make concrete type


"""
abstract type DeformBasis{T <: SmashProductLieElem} end
A basis for a deformation map space of a Lie algebra smash product.
The constructor of a subtype should accept a [`SmashProductLie`](@ref) and an `AbstractVector{Int}` of degrees.
It is required that `Base.length` and `Base.iterate` are implemented for subtypes,
where iterating yields objects of type `DeformationMap{C}`.
For a reference implementation, we refer to [`StdDeformBasis`](@ref).
"""
abstract type DeformBasis{T <: SmashProductLieElem} end

################################################################################
#
# Smash product deformations
Expand All @@ -299,13 +299,13 @@ It gets created by calling [`deform`](@ref).
NCRing
sp::SmashProductLie{C, LieC, LieT}
rels::Matrix{Union{Nothing, FreeAssAlgElem{C}}}
kappa::DeformationMap{C}
kappa::DeformationMap{SmashProductLieElem{C, LieC, LieT}}

# default constructor for @attributes
function SmashProductLieDeform{C, LieC, LieT}(
sp::SmashProductLie{C, LieC, LieT},
rels::Matrix{Union{Nothing, FreeAssAlgElem{C}}},
kappa::DeformationMap{C},
kappa::DeformationMap{SmashProductLieElem{C, LieC, LieT}},
) where {C <: RingElem, LieC <: FieldElem, LieT <: LieAlgebraElem{LieC}}
new{C, LieC, LieT}(sp, rels, kappa)
end
Expand Down
Loading

0 comments on commit c45e9c7

Please sign in to comment.