further tests

This commit is contained in:
kalmar 2017-05-12 20:49:02 +02:00
parent f2e5eebecf
commit 639c05b4fa
1 changed files with 129 additions and 128 deletions

View File

@ -120,8 +120,8 @@ using Base.Test
end end
@testset "replacements" begin @testset "replacements" begin
a = FPSymbol("a") a = Groups.FreeSymbol("a")
b = FPSymbol("b") b = Groups.FreeSymbol("b")
@test Groups.is_subsymbol(a, Groups.change_pow(a,2)) == true @test Groups.is_subsymbol(a, Groups.change_pow(a,2)) == true
@test Groups.is_subsymbol(a, Groups.change_pow(a,-2)) == false @test Groups.is_subsymbol(a, Groups.change_pow(a,-2)) == false
@test Groups.is_subsymbol(b, Groups.change_pow(a,-2)) == false @test Groups.is_subsymbol(b, Groups.change_pow(a,-2)) == false
@ -132,7 +132,7 @@ using Base.Test
@test findnext(c*s^-1*t^-1, s^-1*t^-1,4) == 5 @test findnext(c*s^-1*t^-1, s^-1*t^-1,4) == 5
@test findfirst(c*t, c) == 0 @test findfirst(c*t, c) == 0
w = s*t*s^-1 w = s*t*s^-1
subst = Dict{FPGroupElem, FPGroupElem}(w => s^1, s*t^-1 => t^4) subst = Dict{FreeGroupElem, FreeGroupElem}(w => s^1, s*t^-1 => t^4)
@test Groups.replace(c, 1, s*t, G()) == s^-1*t^-1 @test Groups.replace(c, 1, s*t, G()) == s^-1*t^-1
@test Groups.replace(c, 1, w, subst[w]) == s*t^-1 @test Groups.replace(c, 1, w, subst[w]) == s*t^-1
@test Groups.replace(s*c*t^-1, 1, w, subst[w]) == s^2*t^-2 @test Groups.replace(s*c*t^-1, 1, w, subst[w]) == s^2*t^-2
@ -141,141 +141,142 @@ using Base.Test
end end
end end
@testset "Automorphisms" begin @testset "Automorphisms" begin
@testset "AutSymbol" begin @testset "AutSymbol" begin
@test_throws MethodError AutSymbol("a") @test_throws MethodError AutSymbol("a")
@test_throws MethodError AutSymbol("a", 1) @test_throws MethodError AutSymbol("a", 1)
f = AutSymbol("a", 1, :(a()), v -> v) f = AutSymbol("a", 1, :(a()), v -> v)
@test isa(f, GSymbol) @test isa(f, Groups.GSymbol)
@test isa(f, AutSymbol) @test isa(f, Groups.AutSymbol)
@test isa(symmetric_AutSymbol([1,2,3,4]), AutSymbol) @test isa(symmetric_AutSymbol([1,2,3,4]), AutSymbol)
@test isa(rmul_AutSymbol(1,2), AutSymbol) @test isa(rmul_AutSymbol(1,2), AutSymbol)
@test isa(lmul_AutSymbol(3,4), AutSymbol) @test isa(lmul_AutSymbol(3,4), AutSymbol)
@test isa(flip_AutSymbol(3), AutSymbol) @test isa(flip_AutSymbol(3), AutSymbol)
end end
@testset "flip_AutSymbol correctness" begin # @testset "flip_AutSymbol correctness" begin
a,b,c,d = [FPGroupElem(FPSymbol(i)) for i in ["a", "b", "c", "d"]] # a,b,c,d = [FreeGroupElem(Groups.FreeSymbol(i)) for i in ["a", "b", "c", "d"]]
domain = [a,b,c,d] # domain = [a,b,c,d]
@test flip_AutSymbol(1)(domain) == [a^-1, b,c,d] # @test flip_AutSymbol(1)(domain) == [a^-1, b,c,d]
@test flip_AutSymbol(2)(domain) == [a, b^-1,c,d] # @test flip_AutSymbol(2)(domain) == [a, b^-1,c,d]
@test flip_AutSymbol(3)(domain) == [a, b,c^-1,d] # @test flip_AutSymbol(3)(domain) == [a, b,c^-1,d]
@test flip_AutSymbol(4)(domain) == [a, b,c,d^-1] # @test flip_AutSymbol(4)(domain) == [a, b,c,d^-1]
@test inv(flip_AutSymbol(1))(domain) == [a^-1, b,c,d] # @test inv(flip_AutSymbol(1))(domain) == [a^-1, b,c,d]
@test inv(flip_AutSymbol(2))(domain) == [a, b^-1,c,d] # @test inv(flip_AutSymbol(2))(domain) == [a, b^-1,c,d]
@test inv(flip_AutSymbol(3))(domain) == [a, b,c^-1,d] # @test inv(flip_AutSymbol(3))(domain) == [a, b,c^-1,d]
@test inv(flip_AutSymbol(4))(domain) == [a, b,c,d^-1] # @test inv(flip_AutSymbol(4))(domain) == [a, b,c,d^-1]
end # end
#
@testset "symmetric_AutSymbol correctness" begin # @testset "symmetric_AutSymbol correctness" begin
a,b,c,d = [FPGroupElem(FPSymbol(i)) for i in ["a", "b", "c", "d"]] # a,b,c,d = [FreeGroupElem(Groups.FreeSymbol(i)) for i in ["a", "b", "c", "d"]]
domain = [a,b,c,d] # domain = [a,b,c,d]
σ = symmetric_AutSymbol([1,2,3,4]) # σ = symmetric_AutSymbol([1,2,3,4])
@test σ(domain) == domain # @test σ(domain) == domain
@test inv(σ)(domain) == domain # @test inv(σ)(domain) == domain
#
σ = symmetric_AutSymbol([2,3,4,1]) # σ = symmetric_AutSymbol([2,3,4,1])
@test σ(domain) == [b, c, d, a] # @test σ(domain) == [b, c, d, a]
@test inv(σ)(domain) == [d, a, b, c] # @test inv(σ)(domain) == [d, a, b, c]
#
σ = symmetric_AutSymbol([2,1,4,3]) # σ = symmetric_AutSymbol([2,1,4,3])
@test σ(domain) == [b, a, d, c] # @test σ(domain) == [b, a, d, c]
@test inv(σ)(domain) == [b, a, d, c] # @test inv(σ)(domain) == [b, a, d, c]
#
σ = symmetric_AutSymbol([2,3,1,4]) # σ = symmetric_AutSymbol([2,3,1,4])
@test σ(domain) == [b,c,a,d] # @test σ(domain) == [b,c,a,d]
@test inv(σ)(domain) == [c,a,b,d] # @test inv(σ)(domain) == [c,a,b,d]
end # end
#
@testset "mul_AutSymbol correctness" begin # @testset "mul_AutSymbol correctness" begin
a,b,c,d = [FPGroupElem(FPSymbol(i)) for i in ["a", "b", "c", "d"]] # a,b,c,d = [FreeGroupElem(Groups.FreeSymbol(i)) for i in ["a", "b", "c", "d"]]
domain = [a,b,c,d] # domain = [a,b,c,d]
i,j = 1,2 # i,j = 1,2
r = rmul_AutSymbol(i,j) # r = rmul_AutSymbol(i,j)
l = lmul_AutSymbol(i,j) # l = lmul_AutSymbol(i,j)
@test r(domain) == [a*b,b,c,d] # @test r(domain) == [a*b,b,c,d]
@test inv(r)(domain) == [a*b^-1,b,c,d] # @test inv(r)(domain) == [a*b^-1,b,c,d]
@test l(domain) == [b*a,b,c,d] # @test l(domain) == [b*a,b,c,d]
@test inv(l)(domain) == [b^-1*a,b,c,d] # @test inv(l)(domain) == [b^-1*a,b,c,d]
#
i,j = 3,1 # i,j = 3,1
r = rmul_AutSymbol(i,j) # r = rmul_AutSymbol(i,j)
l = lmul_AutSymbol(i,j) # l = lmul_AutSymbol(i,j)
@test r(domain) == [a,b,c*a,d] # @test r(domain) == [a,b,c*a,d]
@test inv(r)(domain) == [a,b,c*a^-1,d] # @test inv(r)(domain) == [a,b,c*a^-1,d]
@test l(domain) == [a,b,a*c,d] # @test l(domain) == [a,b,a*c,d]
@test inv(l)(domain) == [a,b,a^-1*c,d] # @test inv(l)(domain) == [a,b,a^-1*c,d]
#
#
i,j = 4,3 # i,j = 4,3
r = rmul_AutSymbol(i,j) # r = rmul_AutSymbol(i,j)
l = lmul_AutSymbol(i,j) # l = lmul_AutSymbol(i,j)
@test r(domain) == [a,b,c,d*c] # @test r(domain) == [a,b,c,d*c]
@test inv(r)(domain) == [a,b,c,d*c^-1] # @test inv(r)(domain) == [a,b,c,d*c^-1]
@test l(domain) == [a,b,c,c*d] # @test l(domain) == [a,b,c,c*d]
@test inv(l)(domain) == [a,b,c,c^-1*d] # @test inv(l)(domain) == [a,b,c,c^-1*d]
#
#
i,j = 2,4 # i,j = 2,4
r = rmul_AutSymbol(i,j) # r = rmul_AutSymbol(i,j)
l = lmul_AutSymbol(i,j) # l = lmul_AutSymbol(i,j)
@test r(domain) == [a,b*d,c,d] # @test r(domain) == [a,b*d,c,d]
@test inv(r)(domain) == [a,b*d^-1,c,d] # @test inv(r)(domain) == [a,b*d^-1,c,d]
@test l(domain) == [a,d*b,c,d] # @test l(domain) == [a,d*b,c,d]
@test inv(l)(domain) == [a,d^-1*b,c,d] # @test inv(l)(domain) == [a,d^-1*b,c,d]
end # end
#
@testset "AutWords" begin # @testset "AutWords" begin
f = AutSymbol("a", 1, :(a()), v -> v) # f = AutSymbol("a", 1, :(a()), v -> v)
@test isa(GWord(f), GWord) # @test isa(GWord(f), GWord)
@test isa(GWord(f), AutWord) # @test isa(GWord(f), AutWord)
@test isa(AutWord(f), AutWord) # @test isa(AutWord(f), AutWord)
@test isa(f*f, AutWord) # @test isa(f*f, AutWord)
@test isa(f^2, AutWord) # @test isa(f^2, AutWord)
@test isa(f^-1, AutWord) # @test isa(f^-1, AutWord)
end # end
#
@testset "eltary functions" begin # @testset "eltary functions" begin
f = symmetric_AutSymbol([2,1,4,3]) # f = symmetric_AutSymbol([2,1,4,3])
@test isa(inv(f), AutSymbol) # @test isa(inv(f), AutSymbol)
@test isa(f^-1, AutWord) # @test isa(f^-1, AutWord)
@test f^-1 == GWord(inv(f)) # @test f^-1 == GWord(inv(f))
@test inv(f) == f # @test inv(f) == f
end # end
#
@testset "reductions/arithmetic" begin # @testset "reductions/arithmetic" begin
f = symmetric_AutSymbol([2,1,4,3]) # f = symmetric_AutSymbol([2,1,4,3])
= Groups.r_multiply(AutWord(f), [f], reduced=false) # f² = Groups.r_multiply(AutWord(f), [f], reduced=false)
@test Groups.simplify_perms!() == false # @test Groups.simplify_perms!(f²) == false
@test == one(typeof(f*f)) # @test f² == one(typeof(f*f))
#
a = rmul_AutSymbol(1,2)*flip_AutSymbol(2) # a = rmul_AutSymbol(1,2)*flip_AutSymbol(2)
b = flip_AutSymbol(2)*inv(rmul_AutSymbol(1,2)) # b = flip_AutSymbol(2)*inv(rmul_AutSymbol(1,2))
@test a*b == b*a # @test a*b == b*a
@test a^3 * b^3 == one(a) # @test a^3 * b^3 == one(a)
end # end
#
@testset "specific Aut(𝔽₄) tests" begin # @testset "specific Aut(𝔽₄) tests" begin
N = 4 # N = 4
import Combinatorics.nthperm # import Combinatorics.nthperm
SymmetricGroup(n) = [nthperm(collect(1:n), k) for k in 1:factorial(n)] # SymmetricGroup(n) = [nthperm(collect(1:n), k) for k in 1:factorial(n)]
indexing = [[i,j] for i in 1:N for j in 1:N if i≠j] # indexing = [[i,j] for i in 1:N for j in 1:N if i≠j]
#
σs = [symmetric_AutSymbol(perm) for perm in SymmetricGroup(N)[2:end]]; # σs = [symmetric_AutSymbol(perm) for perm in SymmetricGroup(N)[2:end]];
ϱs = [rmul_AutSymbol(i,j) for (i,j) in indexing] # ϱs = [rmul_AutSymbol(i,j) for (i,j) in indexing]
λs = [lmul_AutSymbol(i,j) for (i,j) in indexing] # λs = [lmul_AutSymbol(i,j) for (i,j) in indexing]
ɛs = [flip_AutSymbol(i) for i in 1:N]; # ɛs = [flip_AutSymbol(i) for i in 1:N];
#
S = vcat(ϱs, λs, σs, ɛs) # S = vcat(ϱs, λs, σs, ɛs)
S = vcat(S, [inv(s) for s in S]) # S = vcat(S, [inv(s) for s in S])
@test isa(S, Vector{AutSymbol}) # @test isa(S, Vector{AutSymbol})
@test length(S) == 102 # @test length(S) == 102
@test length(unique(S)) == 75 # @test length(unique(S)) == 75
S₁ = [GWord(s) for s in unique(S)] # S₁ = [GWord(s) for s in unique(S)]
@test isa(S₁, Vector{AutWord}) # @test isa(S₁, Vector{AutWord})
p = prod(S₁) # p = prod(S₁)
@test length(p) == 53 # @test length(p) == 53
end # end
end # end
end end