Groups.jl/test/fp_groups.jl

95 lines
2.5 KiB
Julia
Raw Normal View History

2021-05-24 14:46:54 +02:00
@testset "FPGroups" begin
2022-10-14 01:14:38 +02:00
A = Alphabet([:a, :A, :b, :B, :c, :C], [2, 1, 4, 3, 6, 5])
2021-05-24 14:46:54 +02:00
@test FreeGroup(A) isa FreeGroup
@test sprint(show, FreeGroup(A)) == "free group on 3 generators"
F = FreeGroup([:a, :b, :c], Groups.KnuthBendix.LenLex(A))
@test sprint(show, F) == "free group on 3 generators"
2021-05-24 14:46:54 +02:00
2022-10-14 01:14:38 +02:00
a, b, c = gens(F)
@test c * b * a isa FPGroupElement
2021-05-24 14:46:54 +02:00
# quotient of F:
2022-10-14 01:14:38 +02:00
G = FPGroup(F, [a * b => b * a, a * c => c * a, b * c => c * b])
2021-05-24 14:46:54 +02:00
@test G isa FPGroup
2023-05-29 17:40:56 +02:00
@test sprint(show, G) ==
"⟨ a b c | \n\t a*b => b*a a*c => c*a b*c => c*b ⟩"
@test rand(G) isa FPGroupElement
2021-05-24 14:46:54 +02:00
2022-10-14 01:14:38 +02:00
f = a * c * b
@test word(f) isa Word{UInt8}
2021-05-24 14:46:54 +02:00
2022-10-14 01:14:38 +02:00
aG, bG, cG = gens(G)
2021-05-24 14:46:54 +02:00
@test aG isa FPGroupElement
2021-05-24 14:46:54 +02:00
@test_throws AssertionError aG == a
@test word(aG) == word(a)
2021-05-24 14:46:54 +02:00
2022-10-14 01:14:38 +02:00
g = aG * cG * bG
2021-05-24 14:46:54 +02:00
@test_throws AssertionError f == g
@test word(f) == word(g)
@test word(g) == [1, 5, 3]
Groups.normalform!(g)
@test word(g) == [1, 3, 5]
2021-05-24 14:46:54 +02:00
2022-10-14 01:14:38 +02:00
let g = aG * cG * bG
2021-06-21 17:53:29 +02:00
# test that we normalize g before printing
@test sprint(show, g) == "a*b*c"
end
2021-05-24 14:46:54 +02:00
# quotient of G
2023-05-29 17:40:56 +02:00
H = FPGroup(G, [aG^2 => cG, bG * cG => aG]; max_rules = 200)
2021-05-24 14:46:54 +02:00
h = H(word(g))
2021-05-24 14:46:54 +02:00
@test h isa FPGroupElement
2021-05-24 14:46:54 +02:00
@test_throws AssertionError h == g
2022-10-14 01:14:38 +02:00
@test_throws MethodError h * g
2021-07-07 12:11:45 +02:00
2023-05-29 17:40:56 +02:00
H = FPGroup(G, [aG^2 => cG, bG * cG => aG]; max_rules = 200)
2021-07-07 12:11:45 +02:00
@test_throws AssertionError one(H) == one(H)
2021-05-24 14:46:54 +02:00
Groups.normalform!(h)
2021-05-24 14:46:54 +02:00
@test h == H([5])
2023-05-29 17:40:56 +02:00
@test_logs (
:warn,
"using generic isfiniteorder(::AbstractFPGroupElement): the returned `false` might be wrong",
) isfiniteorder(h)
2022-04-02 15:51:29 +02:00
2023-05-29 17:40:56 +02:00
@test_logs (
:warn,
"using generic isfinite(::AbstractFPGroup): the returned `false` might be wrong",
) isfinite(H)
2022-04-02 15:51:29 +02:00
Logging.with_logger(Logging.NullLogger()) do
@testset "GroupsCore conformance: H" begin
test_Group_interface(H)
test_GroupElement_interface(rand(H, 2)...)
end
end
2023-05-25 11:58:32 +02:00
@testset "hash/normalform #28" begin
function cyclic_group(n::Integer)
A = Alphabet([:a, :A], [2, 1])
F = FreeGroup(A)
a, = Groups.gens(F)
e = one(F)
Cₙ = FPGroup(F, [a^n => e])
return Cₙ
end
n = 15
G = cyclic_group(n)
ball, sizes = Groups.wlmetric_ball(gens(G); radius = n)
@test first(sizes) == 2
@test last(sizes) == n
@test Set(ball) == Set([first(gens(G))^i for i in 0:n-1])
end
2021-05-24 14:46:54 +02:00
end