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

create FreeGroup(::Alphabet) on the correct number of gens

This commit is contained in:
Marek Kaluba 2021-06-21 17:52:51 +02:00
parent 25934e70f4
commit 8cb64d947d
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 14 additions and 1 deletions

View File

@ -131,7 +131,16 @@ end
function FreeGroup(A::Alphabet)
@boundscheck @assert all(KnuthBendix.hasinverse(l, A) for l in KnuthBendix.letters(A))
return FreeGroup(KnuthBendix.letters(A), A)
ltrs = KnuthBendix.letters(A)
gens = Vector{eltype(ltrs)}()
invs = Vector{eltype(ltrs)}()
for l in ltrs
l invs && continue
push!(gens, l)
push!(invs, inv(A, l))
end
return FreeGroup(gens, A)
end
function FreeGroup(n::Integer)

View File

@ -1,7 +1,11 @@
@testset "FPGroups" begin
A = Alphabet([:a, :A, :b, :B, :c, :C], [2,1,4,3,6,5])
@test New.FreeGroup(A) isa New.FreeGroup
@test sprint(show, New.FreeGroup(A)) == "free group on 3 generators"
F = New.FreeGroup([:a, :b, :c], A)
@test sprint(show, F) == "free group on 3 generators"
a,b,c = gens(F)
@test c*b*a isa New.FPGroupElement