Skip to content

Commit

Permalink
changed transitivity (#1713)
Browse files Browse the repository at this point in the history
* changed `transitivity`

`transitivity` now throws an exception if the group does not act
on the given set.

The problem was observed and discussed in pull request  #1671.

* adjusted the transitivity tests

adjusted the tests to the changed definition

* adjusted one more test

* follow the advices
  • Loading branch information
ThomasBreuer authored Nov 17, 2022
1 parent 9d053cc commit 4793558
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
32 changes: 28 additions & 4 deletions src/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,12 @@ end
"""
transitivity(G::PermGroup, L::AbstractVector{Int} = 1:degree(G))
Return the maximum `k` such that the action of `G` on `L` is
`k`-transitive. The output is `0` if `G` is not transitive on `L`.
Return the maximum `k` such that `G` acts `k`-transitively on `L`,
that is, every `k`-tuple of points in `L` can be mapped simultaneously
to every other `k`-tuple by an element of `G`.
The output is `0` if `G` acts intransitively on `L`,
and an exception is thrown if `G` does not act on `L`.
# Examples
```jldoctest
Expand All @@ -838,14 +842,34 @@ julia> transitivity(mathieu_group(24))
julia> transitivity(symmetric_group(6))
6
julia> transitivity(symmetric_group(6), 1:7)
0
julia> transitivity(symmetric_group(6), 1:5)
ERROR: ArgumentError: the group does not act
```
"""
transitivity(G::PermGroup, L::AbstractVector{Int} = 1:degree(G)) = GAP.Globals.Transitivity(G.X, GapObj(L))::Int
function transitivity(G::PermGroup, L::AbstractVector{Int} = 1:degree(G))
gL = GapObj(L)
res = GAP.Globals.Transitivity(G.X, gL)::Int
res === GAP.Globals.fail && throw(ArgumentError("the group does not act"))
# If the result is `0` then it may be that `G` does not act on `L`,
# and in this case we want to throw an exception.
if res == 0 && length(L) > 0
lens = GAP.Globals.OrbitLengths(G.X, gL)
#TODO: Compute the orbit lengths more efficiently than GAP does.
if sum(lens) != length(L)
throw(ArgumentError("the group does not act"))
end
end
return res
end

"""
is_transitive(G::PermGroup, L::AbstractVector{Int} = 1:degree(G))
Return whether the action of `G` on `L` is transitive.
Return whether `G` acts transitively on `L`, that is,
`L` is an orbit of `G`.
# Examples
```jldoctest
Expand Down
2 changes: 1 addition & 1 deletion test/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ end
# transitivity
@test transitivity(G8) == 1
@test transitivity(S4) == 4
@test transitivity(S4, 1:3) == 0
@test_throws ArgumentError transitivity(S4, 1:3)
@test transitivity(S4, 1:4) == 4
@test transitivity(S4, 1:5) == 0

Expand Down
12 changes: 8 additions & 4 deletions test/Groups/libraries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ end
H4 = sub(G,[G([3,4,1,2]), G([2,1,4,3])])[1] # Klein subgroup
L = [G,H1,H2,H3,H4]

# FIXME: the following two tests are fishy. The first couple calls
# really should result in errors ?!?
@test [transitivity(G,1:i) for i in 1:5]==[0,0,0,4,0]
@test [transitivity(L[5],1:i) for i in 1:5]==[0,0,0,1,0]
@test transitivity(G) == 4
@test transitivity(G, 1:4) == 4
@test_throws ArgumentError transitivity(G, 1:3)
@test transitivity(G, 1:5) == 0
@test transitivity(H4) == 1
@test transitivity(H4, 1:4) == 1
@test_throws ArgumentError transitivity(H4, 1:3)
@test transitivity(H4, 1:5) == 0

@test is_transitive(G)
H = sub(G,[G([2,3,1,4])])[1]
Expand Down

0 comments on commit 4793558

Please sign in to comment.