1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 02:05:30 +01:00

add rewriting function to AbstractFPGroups

This commit is contained in:
Marek Kaluba 2021-05-05 02:32:27 +02:00
parent 9d7596acf1
commit 288f06c070
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 9 additions and 4 deletions

View File

@ -13,11 +13,14 @@ using Random
An Abstract type representing finitely presented groups. Every instance `` must implement
* `KnuthBendix.alphabet(G::MyFPGroup)`
* `rewriting(G::MyFPGroup)` : return the rewriting object which must implement
> `KnuthBendix.rewrite_from_left!(u, v, rewriting(G))`.
By default `alphabet(G)` is returned, which amounts to free rewriting in `G`.
By default `word_type(::Type{MyFPGroup}) = Word{UInt16}` returns the default
word type used for group elements. You may wish to override this if e.g. to
AbstractFPGroup may also override `word_type(::Type{MyFPGroup}) = Word{UInt16}`,
which controls the word type used for group elements. If if your group has less
than `255` generators you may define
> `word_type(::Type{MyFPGroup}) = Word{UInt8}`
if your group has less than `255` generators.
"""
abstract type AbstractFPGroup <: GroupsCore.Group end
@ -25,6 +28,8 @@ word_type(G::AbstractFPGroup) = word_type(typeof(G))
# the default:
word_type(::Type{<:AbstractFPGroup}) = Word{UInt16}
rewriting(G::AbstractFPGroup) = alphabet(G)
function (G::AbstractFPGroup)(word::AbstractVector{<:Integer})
@boundscheck @assert all(l -> 1<= l <=length(KnuthBendix.alphabet(G)), word)
return FPGroupElement(word_type(G)(word), G)

View File

@ -44,7 +44,7 @@ Defaults to the rewriting in the free group.
if isnormalform(g) && inv(alphabet(g), last(out)) != first(word(g))
return append!(res, word(g))
end
return free_rewrite!(res, word(g), alphabet(g))
return KnuthBendix.rewrite_from_left!(res, word(g), rewriting(parent(g)))
end
"""