diff --git a/src/new_types.jl b/src/new_types.jl index ff49ee5..576ccbd 100644 --- a/src/new_types.jl +++ b/src/new_types.jl @@ -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) diff --git a/src/normalform.jl b/src/normalform.jl index 945cfc2..76ef5dd 100644 --- a/src/normalform.jl +++ b/src/normalform.jl @@ -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 """