2017-05-09 17:46:52 +02:00
|
|
|
|
|
|
|
|
2017-05-11 18:14:59 +02:00
|
|
|
immutable FPSymbol <: GSymbol
|
|
|
|
str::String
|
|
|
|
pow::Int
|
|
|
|
end
|
|
|
|
|
|
|
|
typealias FPGroupElem GWord{FPSymbol}
|
2017-05-09 17:46:52 +02:00
|
|
|
|
2017-05-11 18:16:21 +02:00
|
|
|
type FPGroup <: Group
|
|
|
|
gens::Vector{FPSymbol}
|
|
|
|
rels::Vector{FPGroupElem}
|
|
|
|
# order::Vector{T}
|
|
|
|
# fastmult_table::Array{Int,2}
|
|
|
|
function FPGroup{T<:GSymbol}(gens::Vector{T}, rels::Vector{GWord{T}})
|
|
|
|
G = new(gens, rels)
|
|
|
|
G.gens = gens
|
|
|
|
rels = [G(r) for r in rels]
|
|
|
|
G.rels = rels
|
|
|
|
return G
|
|
|
|
end
|
2017-05-09 17:46:52 +02:00
|
|
|
end
|
|
|
|
|
2017-05-11 18:17:08 +02:00
|
|
|
export FPSymbol, FPGroupElem, FPGroup, generators
|
2017-05-09 17:46:52 +02:00
|
|
|
|
2017-05-11 18:17:42 +02:00
|
|
|
parent_type(::Type{FPGroupElem}) = FPGroup
|
|
|
|
|
|
|
|
elem_type(::FPGroup) = FPGroupElem
|
|
|
|
|
2017-05-09 17:46:52 +02:00
|
|
|
|
2017-05-11 18:16:51 +02:00
|
|
|
FPSymbol(s::String) = FPSymbol(s,1)
|
|
|
|
|
|
|
|
FPGroup(a::Vector{String}) = FPGroup([FPSymbol(i) for i in a], FPGroupElem[])
|
|
|
|
|
2017-05-09 17:46:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
FPGroup() = FPGroup(Vector{FPSymbol}(), Vector{GWord{FPSymbol}}())
|
|
|
|
|
|
|
|
function show(io::IO, G::FPGroup)
|
|
|
|
print(io, "Finitely presented group on $(length(G.gens)) gens and $(length(G.rels)) relations:\n")
|
|
|
|
print(io, "gens:\t", join([g.gen for g in G.gens], ","),"\n")
|
|
|
|
print(io, "rels:\t", join([rel for rel in G.rels], ","),"\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
function add_gen!{T<:GSymbol}(G::FPGroup, g::T)
|
|
|
|
if !(g in G.gens)
|
|
|
|
push!(G.gens, g)
|
|
|
|
end
|
|
|
|
return G
|
|
|
|
end
|
|
|
|
|
|
|
|
function add_rel!{T<:FPSymbol}(G::FPGroup, w::GWord{T})
|
|
|
|
if !(w in G.rels)
|
|
|
|
push!(G.rels, w)
|
|
|
|
end
|
|
|
|
return G
|
|
|
|
end
|
|
|
|
|
|
|
|
end #of module FinitelyPresentedGroups
|