mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 02:05:30 +01:00
create FreeGroup(::Alphabet) on the correct number of gens
This commit is contained in:
parent
25934e70f4
commit
8cb64d947d
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user