1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

tidy a bit alphabet/ordering/rewriting requirements

This commit is contained in:
Marek Kaluba 2022-10-14 01:03:19 +02:00
parent 827969ae84
commit 5752d67009
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
5 changed files with 19 additions and 20 deletions

View File

@ -10,7 +10,7 @@ import OrderedCollections: OrderedSet
import KnuthBendix
import KnuthBendix: AbstractWord, Alphabet, Word
import KnuthBendix: alphabet
import KnuthBendix: alphabet, ordering
export MatrixGroups

View File

@ -1,9 +1,9 @@
struct SurfaceGroup{T, S, R} <: AbstractFPGroup
struct SurfaceGroup{T,S,RW} <: AbstractFPGroup
genus::Int
boundaries::Int
gens::Vector{T}
relations::Vector{<:Pair{S,S}}
rws::R
rw::RW
end
include("symplectic_twists.jl")
@ -69,8 +69,7 @@ function SurfaceGroup(genus::Integer, boundaries::Integer)
return SurfaceGroup(genus, boundaries, [Al[i] for i in 2:2:length(Al)], rels, rws)
end
rewriting(S::SurfaceGroup) = S.rws
KnuthBendix.alphabet(S::SurfaceGroup) = alphabet(rewriting(S))
rewriting(S::SurfaceGroup) = S.rw
relations(S::SurfaceGroup) = S.relations
function symplectic_twists(π₁Σ::SurfaceGroup)

View File

@ -19,8 +19,6 @@ function SpecialAutomorphismGroup(F::FreeGroup; ordering = KnuthBendix.LenLex, k
return AutomorphismGroup(F, S, idxA, ntuple(i -> gens(F, i), n))
end
KnuthBendix.alphabet(G::AutomorphismGroup{<:FreeGroup}) = alphabet(rewriting(G))
function relations(G::AutomorphismGroup{<:FreeGroup})
n = length(alphabet(object(G))) ÷ 2
return last(gersten_relations(n, commutative = false))

View File

@ -4,15 +4,15 @@ function KnuthBendix.Alphabet(S::AbstractVector{<:GSymbol})
return Alphabet(S, inversions)
end
struct AutomorphismGroup{G<:Group,T,R,S} <: AbstractFPGroup
struct AutomorphismGroup{G<:Group,T,RW,S} <: AbstractFPGroup
group::G
gens::Vector{T}
rws::R
rw::RW
domain::S
end
object(G::AutomorphismGroup) = G.group
rewriting(G::AutomorphismGroup) = G.rws
rewriting(G::AutomorphismGroup) = G.rw
function equality_data(f::AbstractFPGroupElement{<:AutomorphismGroup})
imf = evaluate(f)

View File

@ -7,7 +7,9 @@ An Abstract type representing finitely presented groups. Every instance must imp
* `KnuthBendix.alphabet(G::MyFPGroup)`
* `rewriting(G::MyFPGroup)` : return the rewriting object which must implement
> `KnuthBendix.rewrite!(u, v, rewriting(G))`.
By default `alphabet(G)` is returned, which amounts to free rewriting in `G`.
E.g. for `G::FreeGroup` `alphabet(G)` is returned, which amounts to free rewriting.
* `ordering(G::MyFPGroup)[ = KnuthBendix.ordering(rewriting(G))]` : return the
(implicit) ordering for the alphabet of `G`.
* `relations(G::MyFPGroup)` : return a set of defining relations.
AbstractFPGroup may also override `word_type(::Type{MyFPGroup}) = Word{UInt8}`,
@ -34,11 +36,14 @@ in free rewriting. For `FPGroup` a rewriting system is returned which may
"""
function rewriting end
KnuthBendix.ordering(G::AbstractFPGroup) = ordering(rewriting(G))
KnuthBendix.alphabet(G::AbstractFPGroup) = alphabet(ordering(G))
Base.@propagate_inbounds function (G::AbstractFPGroup)(
word::AbstractVector{<:Integer},
)
@boundscheck @assert all(
l -> 1 <= l <= length(KnuthBendix.alphabet(G)),
l -> 1 <= l <= length(alphabet(G)),
word,
)
return FPGroupElement(word_type(G)(word), G)
@ -192,10 +197,9 @@ Base.show(io::IO, F::FreeGroup) =
print(io, "free group on $(ngens(F)) generators")
# mandatory methods:
relations(F::FreeGroup) = Pair{eltype(F)}[]
KnuthBendix.ordering(F::FreeGroup) = F.ordering
KnuthBendix.alphabet(F::FreeGroup) = alphabet(KnuthBendix.ordering(F))
rewriting(F::FreeGroup) = alphabet(F)
rewriting(F::FreeGroup) = alphabet(F) # alphabet(F) = alphabet(ordering(F))
relations(F::FreeGroup) = Pair{eltype(F),eltype(F)}[]
# GroupsCore interface:
# these are mathematically correct
@ -206,16 +210,14 @@ GroupsCore.isfiniteorder(g::AbstractFPGroupElement{<:FreeGroup}) =
## FP Groups
struct FPGroup{T,R,S} <: AbstractFPGroup
struct FPGroup{T,RW,S} <: AbstractFPGroup
gens::Vector{T}
relations::Vector{Pair{S,S}}
rws::R
rw::RW
end
relations(G::FPGroup) = G.relations
rewriting(G::FPGroup) = G.rws
KnuthBendix.ordering(G::FPGroup) = KnuthBendix.ordering(rewriting(G))
KnuthBendix.alphabet(G::FPGroup) = alphabet(KnuthBendix.ordering(G))
rewriting(G::FPGroup) = G.rw
function FPGroup(
G::AbstractFPGroup,