mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 14:35:28 +01:00
add rewriting function to AbstractFPGroups
This commit is contained in:
parent
9d7596acf1
commit
288f06c070
@ -13,11 +13,14 @@ using Random
|
|||||||
|
|
||||||
An Abstract type representing finitely presented groups. Every instance `` must implement
|
An Abstract type representing finitely presented groups. Every instance `` must implement
|
||||||
* `KnuthBendix.alphabet(G::MyFPGroup)`
|
* `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
|
AbstractFPGroup may also override `word_type(::Type{MyFPGroup}) = Word{UInt16}`,
|
||||||
word type used for group elements. You may wish to override this if e.g. to
|
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}`
|
> `word_type(::Type{MyFPGroup}) = Word{UInt8}`
|
||||||
if your group has less than `255` generators.
|
|
||||||
"""
|
"""
|
||||||
abstract type AbstractFPGroup <: GroupsCore.Group end
|
abstract type AbstractFPGroup <: GroupsCore.Group end
|
||||||
|
|
||||||
@ -25,6 +28,8 @@ word_type(G::AbstractFPGroup) = word_type(typeof(G))
|
|||||||
# the default:
|
# the default:
|
||||||
word_type(::Type{<:AbstractFPGroup}) = Word{UInt16}
|
word_type(::Type{<:AbstractFPGroup}) = Word{UInt16}
|
||||||
|
|
||||||
|
rewriting(G::AbstractFPGroup) = alphabet(G)
|
||||||
|
|
||||||
function (G::AbstractFPGroup)(word::AbstractVector{<:Integer})
|
function (G::AbstractFPGroup)(word::AbstractVector{<:Integer})
|
||||||
@boundscheck @assert all(l -> 1<= l <=length(KnuthBendix.alphabet(G)), word)
|
@boundscheck @assert all(l -> 1<= l <=length(KnuthBendix.alphabet(G)), word)
|
||||||
return FPGroupElement(word_type(G)(word), G)
|
return FPGroupElement(word_type(G)(word), G)
|
||||||
|
@ -44,7 +44,7 @@ Defaults to the rewriting in the free group.
|
|||||||
if isnormalform(g) && inv(alphabet(g), last(out)) != first(word(g))
|
if isnormalform(g) && inv(alphabet(g), last(out)) != first(word(g))
|
||||||
return append!(res, word(g))
|
return append!(res, word(g))
|
||||||
end
|
end
|
||||||
return free_rewrite!(res, word(g), alphabet(g))
|
return KnuthBendix.rewrite_from_left!(res, word(g), rewriting(parent(g)))
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user