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

add exports, remove New module from tests

This commit is contained in:
Marek Kaluba 2021-06-21 18:45:10 +02:00
parent 26781bad5c
commit 8cd1f09d74
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
5 changed files with 76 additions and 75 deletions

View File

@ -5,7 +5,8 @@ using ThreadsX
import KnuthBendix
import OrderedCollections: OrderedSet
export gens, FreeGroup, Aut, SAut
export AutomorphismGroup, FreeGroup, FreeGroup, FPGroup, FPGroupElement, SpecialAutomorphismGroup
export alphabet, evaluate, word
include("new_types.jl")
include("new_hashing.jl")

View File

@ -2,30 +2,30 @@
@testset "Transvections" begin
@test New.Transvection(:ϱ, 1, 2) isa New.GSymbol
@test New.Transvection(:ϱ, 1, 2) isa New.Transvection
@test New.Transvection(, 1, 2) isa New.GSymbol
@test New.Transvection(, 1, 2) isa New.Transvection
t = New.Transvection(:ϱ, 1, 2)
@test inv(t) isa New.GSymbol
@test inv(t) isa New.Transvection
@test Groups.Transvection(:ϱ, 1, 2) isa Groups.GSymbol
@test Groups.Transvection(:ϱ, 1, 2) isa Groups.Transvection
@test Groups.Transvection(, 1, 2) isa Groups.GSymbol
@test Groups.Transvection(, 1, 2) isa Groups.Transvection
t = Groups.Transvection(:ϱ, 1, 2)
@test inv(t) isa Groups.GSymbol
@test inv(t) isa Groups.Transvection
@test t != inv(t)
s = New.Transvection(:ϱ, 1, 2)
s = Groups.Transvection(:ϱ, 1, 2)
@test t == s
@test hash(t) == hash(s)
s_ = New.Transvection(:ϱ, 1, 3)
s_ = Groups.Transvection(:ϱ, 1, 3)
@test s_ != s
@test hash(s_) != hash(s)
@test New.gersten_alphabet(3) isa Alphabet
A = New.gersten_alphabet(3)
@test Groups.gersten_alphabet(3) isa Alphabet
A = Groups.gersten_alphabet(3)
@test length(A) == 12
@test sprint(show, New.ϱ(1, 2)) == "ϱ₁.₂"
@test sprint(show, New.λ(3, 2)) == "λ₃.₂"
@test sprint(show, Groups.ϱ(1, 2)) == "ϱ₁.₂"
@test sprint(show, Groups.λ(3, 2)) == "λ₃.₂"
end
A4 = Alphabet(
@ -38,16 +38,16 @@
[ 2, 1, 4, 3, 6, 5, 8, 7,10, 9]
)
F4 = New.FreeGroup([:a, :b, :c, :d], A4)
F4 = FreeGroup([:a, :b, :c, :d], A4)
a,b,c,d = gens(F4)
D = ntuple(i->gens(F4, i), 4)
@testset "Transvection action correctness" begin
i,j = 1,2
r = New.Transvection(:ϱ,i,j)
l = New.Transvection(,i,j)
r = Groups.Transvection(:ϱ,i,j)
l = Groups.Transvection(,i,j)
(t::New.Transvection)(v::Tuple) = New.evaluate!(v, t, A4)
(t::Groups.Transvection)(v::Tuple) = Groups.evaluate!(v, t, A4)
@test r(deepcopy(D)) == (a*b, b, c, d)
@test inv(r)(deepcopy(D)) == (a*b^-1,b, c, d)
@ -55,48 +55,48 @@
@test inv(l)(deepcopy(D)) == (b^-1*a,b, c, d)
i,j = 3,1
r = New.Transvection(:ϱ,i,j)
l = New.Transvection(,i,j)
r = Groups.Transvection(:ϱ,i,j)
l = Groups.Transvection(,i,j)
@test r(deepcopy(D)) == (a, b, c*a, d)
@test inv(r)(deepcopy(D)) == (a, b, c*a^-1,d)
@test l(deepcopy(D)) == (a, b, a*c, d)
@test inv(l)(deepcopy(D)) == (a, b, a^-1*c,d)
i,j = 4,3
r = New.Transvection(:ϱ,i,j)
l = New.Transvection(,i,j)
r = Groups.Transvection(:ϱ,i,j)
l = Groups.Transvection(,i,j)
@test r(deepcopy(D)) == (a, b, c, d*c)
@test inv(r)(deepcopy(D)) == (a, b, c, d*c^-1)
@test l(deepcopy(D)) == (a, b, c, c*d)
@test inv(l)(deepcopy(D)) == (a, b, c, c^-1*d)
i,j = 2,4
r = New.Transvection(:ϱ,i,j)
l = New.Transvection(,i,j)
r = Groups.Transvection(:ϱ,i,j)
l = Groups.Transvection(,i,j)
@test r(deepcopy(D)) == (a, b*d, c, d)
@test inv(r)(deepcopy(D)) == (a, b*d^-1,c, d)
@test l(deepcopy(D)) == (a, d*b, c, d)
@test inv(l)(deepcopy(D)) == (a, d^-1*b,c, d)
end
A = New.SpecialAutomorphismGroup(F4, maxrules=1000)
A = SpecialAutomorphismGroup(F4, maxrules=1000)
@testset "AutomorphismGroup constructors" begin
@test A isa New.AbstractFPGroup
@test A isa New.AutomorphismGroup
@test KnuthBendix.alphabet(A) isa Alphabet
@test New.relations(A) isa Vector{<:Pair}
@test A isa Groups.AbstractFPGroup
@test A isa AutomorphismGroup
@test alphabet(A) isa Alphabet
@test Groups.relations(A) isa Vector{<:Pair}
@test sprint(show, A) == "automorphism group of free group on 4 generators"
end
@testset "Automorphisms: hash and evaluate" begin
@test New.domain(gens(A, 1)) == D
@test Groups.domain(gens(A, 1)) == D
g, h = gens(A, 1), gens(A, 8)
@test New.evaluate(g*h) == New.evaluate(h*g)
@test evaluate(g*h) == evaluate(h*g)
@test (g*h).savedhash == zero(UInt)
@test sprint(show, typeof(g)) == "Automorphism{Groups.New.FreeGroup{Symbol},…}"
@test sprint(show, typeof(g)) == "Automorphism{FreeGroup{Symbol},…}"
a = g*h
b = h*g
@ -111,22 +111,22 @@
# ϱ₁₂*ϱ₂₁⁻¹*λ₁₂*ε₂ == σ₂₁₃₄
g = gens(A, 1)
x1, x2, x3, x4 = New.domain(g)
@test New.evaluate(g) == (x1*x2, x2, x3, x4)
x1, x2, x3, x4 = Groups.domain(g)
@test evaluate(g) == (x1*x2, x2, x3, x4)
g = g*inv(gens(A, 4)) # ϱ₂₁
@test New.evaluate(g) == (x1*x2, x1^-1, x3, x4)
@test evaluate(g) == (x1*x2, x1^-1, x3, x4)
g = g*gens(A, 13)
@test New.evaluate(g) == (x2, x1^-1, x3, x4)
@test evaluate(g) == (x2, x1^-1, x3, x4)
end
@testset "Automorphisms: SAut(F₄)" begin
N = 4
G = New.SpecialAutomorphismGroup(New.FreeGroup(N))
G = SpecialAutomorphismGroup(FreeGroup(N))
S = gens(G)
@test S isa Vector{<:New.FPGroupElement{<:New.AutomorphismGroup{<:New.FreeGroup}}}
@test S isa Vector{<:FPGroupElement{<:AutomorphismGroup{<:FreeGroup}}}
@test length(S) == 2*N*(N-1)
@test length(unique(S)) == length(S)
@ -157,7 +157,7 @@ end
# using Random
# using GroupsCore
#
# A = New.SpecialAutomorphismGroup(New.FreeGroup(4), maxrules=2000, ordering=KnuthBendix.RecursivePathOrder)
# A = New.SpecialAutomorphismGroup(FreeGroup(4), maxrules=2000, ordering=KnuthBendix.RecursivePathOrder)
#
# # for seed in 1:1000
# let seed = 68
@ -168,22 +168,22 @@ end
# @info "seed=$seed" g h
# @time isone(g*inv(g))
# @time isone(inv(g)*g)
# @info "" length(New.word(New.normalform!(g*inv(g)))) length(New.word(New.normalform!(inv(g)*g)))
# @info "" length(word(New.normalform!(g*inv(g)))) length(word(New.normalform!(inv(g)*g)))
# a = commutator(g, h, g)
# b = conj(inv(g), h) * conj(conj(g, h), g)
#
# @info length(New.word(a))
# @info length(New.word(b))
# @info length(word(a))
# @info length(word(b))
#
# w = a*inv(b)
# @info length(New.word(w))
# @info length(word(w))
# New.normalform!(w)
# @info length(New.word(w))
# @info length(word(w))
#
#
# #
# # @time ima = New.evaluate(a)
# # @time imb = New.evaluate(b)
# # @time ima = evaluate(a)
# # @time imb = evaluate(b)
# # @info "" a b ima imb
# # @time a == b
# end

View File

@ -6,7 +6,7 @@ using Groups.New
function wl_ball(F; radius::Integer)
g, state = iterate(F)
while length(New.word(g)) <= radius
while length(word(g)) <= radius
res = iterate(F, state)
isnothing(res) && break
g, state = res
@ -20,7 +20,7 @@ end
N = 4
@testset "iteration: FreeGroup" begin
FN = New.FreeGroup(N)
FN = FreeGroup(N)
R = 8
let G = FN
@ -46,7 +46,7 @@ end
@testset "iteration: SAut(F_n)" begin
R = 4
FN = New.FreeGroup(N)
FN = FreeGroup(N)
SAutFN = New.SpecialAutomorphismGroup(FN)
let G = SAutFN

View File

@ -1,38 +1,38 @@
@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"
@test FreeGroup(A) isa FreeGroup
@test sprint(show, FreeGroup(A)) == "free group on 3 generators"
F = New.FreeGroup([:a, :b, :c], A)
F = 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
@test c*b*a isa FPGroupElement
# quotient of F:
G = New.FPGroup(F, [a*b=>b*a, a*c=>c*a, b*c=>c*b])
G = FPGroup(F, [a*b=>b*a, a*c=>c*a, b*c=>c*b])
@test G isa New.FPGroup
@test G isa FPGroup
@test sprint(show, G) == "⟨a, b, c | a*b => b*a, a*c => c*a, b*c => c*b⟩"
@test rand(G) isa New.FPGroupElement
@test rand(G) isa FPGroupElement
f = a*c*b
@test New.word(f) isa Word{UInt8}
@test word(f) isa Word{UInt8}
aG,bG,cG = gens(G)
@test aG isa New.FPGroupElement
@test aG isa FPGroupElement
@test_throws AssertionError aG == a
@test New.word(aG) == New.word(a)
@test word(aG) == word(a)
g = aG*cG*bG
@test_throws AssertionError f == g
@test New.word(f) == New.word(g)
@test New.word(g) == [1, 5, 3]
New.normalform!(g)
@test New.word(g) == [1, 3, 5]
@test word(f) == word(g)
@test word(g) == [1, 5, 3]
Groups.normalform!(g)
@test word(g) == [1, 3, 5]
let g = aG*cG*bG
# test that we normalize g before printing
@ -40,15 +40,15 @@
end
# quotient of G
H = New.FPGroup(G, [aG^2=>cG, bG*cG=>aG], maxrules=200)
H = FPGroup(G, [aG^2=>cG, bG*cG=>aG], maxrules=200)
h = H(New.word(g))
h = H(word(g))
@test h isa New.FPGroupElement
@test h isa FPGroupElement
@test_throws AssertionError h == g
@test_throws AssertionError h*g
New.normalform!(h)
Groups.normalform!(h)
@test h == H([5])
@testset "GroupsCore conformance: H" begin

View File

@ -1,12 +1,12 @@
@testset "New.FreeGroup" begin
@testset "FreeGroup" begin
A3 = Alphabet([:a, :b, :c, :A, :B, :C], [4,5,6,1,2,3])
F3 = New.FreeGroup([:a, :b, :c], A3)
@test F3 isa New.FreeGroup
F3 = FreeGroup([:a, :b, :c], A3)
@test F3 isa FreeGroup
@test gens(F3) isa Vector
@test eltype(F3) <: New.FPGroupElement{<:New.FreeGroup}
@test eltype(F3) <: FPGroupElement{<:FreeGroup}
w = F3([1,2,3,4])
W = inv(w)
@ -15,7 +15,7 @@
@test isone(w*W)
@test New.alphabet(w) == A3
@test alphabet(w) == A3
@testset "generic iteration" begin
w, s = iterate(F3)
@ -43,7 +43,7 @@
@testset "wl_ball" begin
function wl_ball(F; radius::Integer)
g, state = iterate(F)
while length(New.word(g)) <= radius
while length(word(g)) <= radius
res = iterate(F, state)
isnothing(res) && break
g, state = res
@ -55,11 +55,11 @@
E4 = wl_ball(F3, radius=4)
@test length(E4) == 937
@test New.word(last(E4)) == Word([6])^4
@test word(last(E4)) == Word([6])^4
E8, t, _ = @timed wl_ball(F3, radius=8)
@test length(E8) == 585937
@test New.word(last(E8)) == Word([6])^8
@test word(last(E8)) == Word([6])^8
@test t/10^9 < 1
end