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

implement and test GroupsCore interface for FreeGroup and FPGroup

This commit is contained in:
Marek Kaluba 2021-05-24 15:35:28 +02:00
parent 9d1678d099
commit ac3d7f0977
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
5 changed files with 23 additions and 1 deletions

View File

@ -9,6 +9,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
KnuthBendix = "c2604015-7b3d-4a30-8a26-9074551ec60a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
[compat]

View File

@ -61,6 +61,8 @@ function Base.rand(rng::Random.AbstractRNG, rs::Random.SamplerTrivial{<:Abstract
return FPGroupElement(word_type(G)(rand(1:nletters, l)), G)
end
Base.isfinite(::AbstractFPGroup) = (@warn "using generic isfinite(::AbstractFPGroup): the returned `false` might be wrong"; false)
## FPGroupElement
mutable struct FPGroupElement{G<:AbstractFPGroup,W<:AbstractWord} <: GroupElement
@ -109,7 +111,7 @@ function Base.:(*)(g::FPGroupElement, h::FPGroupElement)
return FPGroupElement(word(g) * word(h), parent(g))
end
GroupsCore.isfiniteorder(g::FPGroupElement) = isone(g) ? true : throw("Not Implemented")
GroupsCore.isfiniteorder(g::FPGroupElement) = isone(g) ? true : (@warn "using generic isfiniteorder(::FPGroupElement): the returned `false` might be wrong"; false)
# additional methods:
Base.isone(g::FPGroupElement) = (normalform!(g); isempty(word(g)))
@ -138,6 +140,12 @@ Base.show(io::IO, F::FreeGroup) = print(io, "free group on $(ngens(F)) generator
KnuthBendix.alphabet(F::FreeGroup) = F.alphabet
relations(F::FreeGroup) = Pair{eltype(F)}[]
# GroupsCore interface:
# these are mathematically correct
Base.isfinite(::FreeGroup) = false
GroupsCore.isfiniteorder(g::FPGroupElement{<:FreeGroup}) = isone(g) ? true : false
## FP Groups
struct FPGroup{T,R,S} <: AbstractFPGroup

View File

@ -41,4 +41,9 @@
New.normalform!(h)
@test h == H([5])
@testset "GroupsCore conformance: H" begin
test_Group_interface(H)
test_GroupElement_interface(rand(H, 2)...)
end
end

View File

@ -62,4 +62,9 @@
@test New.word(last(E8)) == Word([6])^8
end
@testset "GroupsCore conformance" begin
test_Group_interface(F3)
test_GroupElement_interface(rand(F3, 2)...)
end
end

View File

@ -28,6 +28,9 @@ using LinearAlgebra
using Groups.New
using KnuthBendix
using GroupsCore
include(joinpath(pathof(GroupsCore), "..", "..", "test", "conformance_test.jl"))
include("free_groups.jl")
include("fp_groups.jl")
end