mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-26 02:20:30 +01:00
make FPGroups more connected to their freepreimages
This commit is contained in:
parent
2196b7d256
commit
f8aedc207f
@ -13,9 +13,9 @@ 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
|
||||||
@ -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,12 +137,15 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function add_rels!(G::FPGroup, newrels::Dict{FPGroupElem,FPGroupElem})
|
freepreimage(G::FPGroup) = parent(first(keys(G.rels)))
|
||||||
|
freepreimage(g::FPGroupElem) = freepreimage(parent(g))(syllables(g))
|
||||||
|
|
||||||
|
function add_rels!(G::FPGroup, newrels::Dict{FreeGroupElem,FreeGroupElem})
|
||||||
for w in keys(newrels)
|
for w in keys(newrels)
|
||||||
if !(w in keys(G.rels))
|
haskey(G.rels, w) && continue
|
||||||
G.rels[w] = G(newrels[w])
|
G.rels[w] = newrels[w]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return G
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem})
|
function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem})
|
||||||
@ -151,17 +154,18 @@ function Base.:/(G::FPGroup, newrels::Vector{FPGroupElem})
|
|||||||
"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)
|
||||||
|
newrels = Dict(freepreimage(r) => one(F) for r in newrels)
|
||||||
add_rels!(H, newrels)
|
add_rels!(H, newrels)
|
||||||
return H
|
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
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user