mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2025-01-12 22:22:32 +01:00
implement and test GroupsCore interface for FreeGroup and FPGroup
This commit is contained in:
parent
9d1678d099
commit
ac3d7f0977
@ -9,6 +9,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
|||||||
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
|
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
|
||||||
KnuthBendix = "c2604015-7b3d-4a30-8a26-9074551ec60a"
|
KnuthBendix = "c2604015-7b3d-4a30-8a26-9074551ec60a"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
|
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
|
@ -61,6 +61,8 @@ function Base.rand(rng::Random.AbstractRNG, rs::Random.SamplerTrivial{<:Abstract
|
|||||||
return FPGroupElement(word_type(G)(rand(1:nletters, l)), G)
|
return FPGroupElement(word_type(G)(rand(1:nletters, l)), G)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Base.isfinite(::AbstractFPGroup) = (@warn "using generic isfinite(::AbstractFPGroup): the returned `false` might be wrong"; false)
|
||||||
|
|
||||||
## FPGroupElement
|
## FPGroupElement
|
||||||
|
|
||||||
mutable struct FPGroupElement{G<:AbstractFPGroup,W<:AbstractWord} <: GroupElement
|
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))
|
return FPGroupElement(word(g) * word(h), parent(g))
|
||||||
end
|
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:
|
# additional methods:
|
||||||
Base.isone(g::FPGroupElement) = (normalform!(g); isempty(word(g)))
|
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
|
KnuthBendix.alphabet(F::FreeGroup) = F.alphabet
|
||||||
relations(F::FreeGroup) = Pair{eltype(F)}[]
|
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
|
## FP Groups
|
||||||
|
|
||||||
struct FPGroup{T,R,S} <: AbstractFPGroup
|
struct FPGroup{T,R,S} <: AbstractFPGroup
|
||||||
|
@ -41,4 +41,9 @@
|
|||||||
New.normalform!(h)
|
New.normalform!(h)
|
||||||
@test h == H([5])
|
@test h == H([5])
|
||||||
|
|
||||||
|
@testset "GroupsCore conformance: H" begin
|
||||||
|
test_Group_interface(H)
|
||||||
|
test_GroupElement_interface(rand(H, 2)...)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -62,4 +62,9 @@
|
|||||||
@test New.word(last(E8)) == Word([6])^8
|
@test New.word(last(E8)) == Word([6])^8
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@testset "GroupsCore conformance" begin
|
||||||
|
test_Group_interface(F3)
|
||||||
|
test_GroupElement_interface(rand(F3, 2)...)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -28,6 +28,9 @@ using LinearAlgebra
|
|||||||
using Groups.New
|
using Groups.New
|
||||||
using KnuthBendix
|
using KnuthBendix
|
||||||
|
|
||||||
|
using GroupsCore
|
||||||
|
include(joinpath(pathof(GroupsCore), "..", "..", "test", "conformance_test.jl"))
|
||||||
|
|
||||||
include("free_groups.jl")
|
include("free_groups.jl")
|
||||||
include("fp_groups.jl")
|
include("fp_groups.jl")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user