From 5752d670096f09cefeb48d88ab35ab8594a3dfea Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Fri, 14 Oct 2022 01:03:19 +0200 Subject: [PATCH] tidy a bit alphabet/ordering/rewriting requirements --- src/Groups.jl | 2 +- src/aut_groups/mcg.jl | 7 +++---- src/aut_groups/sautFn.jl | 2 -- src/autgroups.jl | 6 +++--- src/types.jl | 22 ++++++++++++---------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Groups.jl b/src/Groups.jl index 7c97e77..f34a7b7 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -10,7 +10,7 @@ import OrderedCollections: OrderedSet import KnuthBendix import KnuthBendix: AbstractWord, Alphabet, Word -import KnuthBendix: alphabet +import KnuthBendix: alphabet, ordering export MatrixGroups diff --git a/src/aut_groups/mcg.jl b/src/aut_groups/mcg.jl index fff9510..7201d25 100644 --- a/src/aut_groups/mcg.jl +++ b/src/aut_groups/mcg.jl @@ -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) diff --git a/src/aut_groups/sautFn.jl b/src/aut_groups/sautFn.jl index fdc37cf..e72e18b 100644 --- a/src/aut_groups/sautFn.jl +++ b/src/aut_groups/sautFn.jl @@ -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)) diff --git a/src/autgroups.jl b/src/autgroups.jl index 30b4bde..09b7f9a 100644 --- a/src/autgroups.jl +++ b/src/autgroups.jl @@ -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) diff --git a/src/types.jl b/src/types.jl index 5ccd283..16eb542 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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,