1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 18:15:29 +01:00

make FPGroups more connected to their freepreimages

This commit is contained in:
kalmarek 2020-03-25 05:00:16 +01:00
parent 2196b7d256
commit f8aedc207f
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 37 additions and 31 deletions

View File

@ -12,14 +12,14 @@ end
FPGroupElem = GroupWord{FPSymbol} FPGroupElem = GroupWord{FPSymbol}
mutable struct FPGroup <: AbstractFPGroup mutable struct FPGroup <: AbstractFPGroup
gens::Vector{FPSymbol} gens::Vector{FPSymbol}
rels::Dict{FPGroupElem, FPGroupElem} rels::Dict{FreeGroupElem, FreeGroupElem}
function FPGroup(gens::Vector{T}, rels::Dict{FPGroupElem, FPGroupElem}) where {T<:GSymbol} function FPGroup(gens::Vector{T}, rels::Dict{FreeGroupElem, FreeGroupElem}) where {T<:GSymbol}
G = new(gens) G = new(gens)
G.rels = Dict(G(k) => G(v) for (k,v) in rels) G.rels = Dict(G(k) => G(v) for (k,v) in rels)
return G return G
end end
end end
export FPGroupElem, FPGroup export FPGroupElem, FPGroup
@ -45,7 +45,7 @@ FPSymbol(s::GSymbol) = FPSymbol(s.id, s.pow)
convert(::Type{FPSymbol}, s::FreeSymbol) = FPSymbol(s.id, s.pow) convert(::Type{FPSymbol}, s::FreeSymbol) = FPSymbol(s.id, s.pow)
FPGroup(gens::Vector{FPSymbol}) = FPGroup(gens, Dict{FPGroupElem, FPGroupElem}()) FPGroup(gens::Vector{FPSymbol}) = FPGroup(gens, Dict{FreeGroupElem, FreeGroupElem}())
FPGroup(a::Vector{String}) = FPGroup([FPSymbol(i) for i in a]) FPGroup(a::Vector{String}) = FPGroup([FPSymbol(i) for i in a])
@ -80,13 +80,13 @@ function (G::FPGroup)(w::GWord)
return reduce!(w) return reduce!(w)
end end
(G::FPGroup)(s::FPSymbol) = G(FPGroupElem(s))
############################################################################### ###############################################################################
# #
# Basic manipulation # Basic manipulation
# #
############################################################################### ###############################################################################
(G::FPGroup)(s::GSymbol) = G(FPGroupElem(s))
############################################################################### ###############################################################################
# #
@ -137,31 +137,35 @@ end
# #
############################################################################### ###############################################################################
function add_rels!(G::FPGroup, newrels::Dict{FPGroupElem,FPGroupElem}) freepreimage(G::FPGroup) = parent(first(keys(G.rels)))
for w in keys(newrels) freepreimage(g::FPGroupElem) = freepreimage(parent(g))(syllables(g))
if !(w in keys(G.rels))
G.rels[w] = G(newrels[w]) function add_rels!(G::FPGroup, newrels::Dict{FreeGroupElem,FreeGroupElem})
end for w in keys(newrels)
end haskey(G.rels, w) && continue
G.rels[w] = newrels[w]
end
return G
end end
function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem}) function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem})
for r in newrels for r in newrels
parent(r) == G || throw(DomainError( parent(r) == G || throw(DomainError(
"Can not form quotient group: $r is not an element of $G")) "Can not form quotient group: $r is not an element of $G"))
end end
H = deepcopy(G) H = deepcopy(G)
newrels = Dict(H(r) => one(H) for r in newrels) F = freepreimage(H)
add_rels!(H, newrels) newrels = Dict(freepreimage(r) => one(F) for r in newrels)
return H add_rels!(H, newrels)
return H
end end
function Base.:/(G::FreeGroup, rels::Vector{FreeGroupElem}) function Base.:/(F::FreeGroup, rels::Vector{FreeGroupElem})
for r in rels for r in rels
parent(r) == G || throw(DomainError( parent(r) == F || throw(DomainError(
"Can not form quotient group: $r is not an element of $G")) "Can not form quotient group: $r is not an element of $F"))
end end
H = FPGroup(deepcopy(G)) G = FPGroup(FPSymbol.(F.gens))
H.rels = Dict(H(rel) => one(H) for rel in unique(rels)) G.rels = Dict(rel => one(F) for rel in unique(rels))
return H return G
end end

View File

@ -16,3 +16,5 @@ function (==)(s::GSymbol, t::GSymbol)
s.pow == t.pow && s.id == t.id && return true s.pow == t.pow && s.id == t.id && return true
return false return false
end end
Base.convert(::Type{GS}, s::GSymbol) where GS<:GSymbol = GS(s.id, s.pow)