diff --git a/src/groups/transvections.jl b/src/groups/transvections.jl index 17b0d89..e405359 100644 --- a/src/groups/transvections.jl +++ b/src/groups/transvections.jl @@ -31,12 +31,11 @@ end function Base.show(io::IO, t::Transvection) id = if t.id === :ϱ - "ϱ" + 'ϱ' else # if t.id === :λ - "λ" + 'λ' end - # print(io, id, Groups.subscriptify(t.i), ".", Groups.subscriptify(t.j)) - print(io, id, "_", t.i, ",", t.j) + print(io, id, subscriptify(t.i), '.', subscriptify(t.j)) t.inv && print(io, "^-1") end diff --git a/src/new_types.jl b/src/new_types.jl index 5195228..99631ca 100644 --- a/src/new_types.jl +++ b/src/new_types.jl @@ -211,3 +211,8 @@ end abstract type GSymbol end Base.literal_pow(::typeof(^), t::GSymbol, ::Val{-1}) = inv(t) + +function subscriptify(n::Integer) + subscript_0 = Int(0x2080) # Char(0x2080) -> subscript 0 + return join([Char(subscript_0 + i) for i in reverse(digits(n))], "") +end diff --git a/test/AutFn.jl b/test/AutFn.jl index ecd469e..a7b293d 100644 --- a/test/AutFn.jl +++ b/test/AutFn.jl @@ -23,6 +23,9 @@ @test New.gersten_alphabet(3) isa Alphabet A = New.gersten_alphabet(3) @test length(A) == 12 + + @test sprint(show, New.ϱ(1, 2)) == "ϱ₁.₂" + @test sprint(show, New.λ(3, 2)) == "λ₃.₂" end A4 = Alphabet( @@ -36,8 +39,6 @@ ) F4 = New.FreeGroup([:a, :b, :c, :d], A4) - A = New.SpecialAutomorphismGroup(F4, maxrules=1000) - a,b,c,d = gens(F4) D = ntuple(i->gens(F4, i), 4) @@ -78,12 +79,14 @@ @test inv(l)(deepcopy(D)) == (a, d^-1*b,c, d) end + A = New.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 sprint(show, A) == "automorphism group of free group on 4 generators" end @testset "Automorphisms: hash and evaluate" begin @@ -93,6 +96,8 @@ @test New.evaluate(g*h) == New.evaluate(h*g) @test (g*h).savedhash == zero(UInt) + @test sprint(show, typeof(g)) == "Automorphism{Groups.New.FreeGroup{Symbol},…}" + a = g*h b = h*g @test hash(a) != zero(UInt) diff --git a/test/fp_groups.jl b/test/fp_groups.jl index d49a032..af50b41 100644 --- a/test/fp_groups.jl +++ b/test/fp_groups.jl @@ -14,6 +14,7 @@ G = New.FPGroup(F, [a*b=>b*a, a*c=>c*a, b*c=>c*b]) @test G isa New.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 f = a*c*b @@ -33,6 +34,11 @@ New.normalform!(g) @test New.word(g) == [1, 3, 5] + let g = aG*cG*bG + # test that we normalize g before printing + @test sprint(show, g) == "a*b*c" + end + # quotient of G H = New.FPGroup(G, [aG^2=>cG, bG*cG=>aG], maxrules=200)