Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add argument check to G-set constructor #4259

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
action_function::Function
seeds

function GSetByElements(G::T, fun::Function, seeds; closed::Bool = false) where {T<:Union{GAPGroup, FinGenAbGroup}}
@assert !isempty(seeds)
function GSetByElements(G::T, fun::Function, seeds; closed::Bool = false, check::Bool = true) where {T<:Union{GAPGroup, FinGenAbGroup}}
@req !isempty(seeds) "seeds for G-set must be nonempty"
check && @req hasmethod(fun, (typeof(first(seeds)), elem_type(T))) "action function does not fit to seeds"
Omega = new{T,eltype(seeds)}(G, fun, seeds, Dict{Symbol,Any}())
closed && set_attribute!(Omega, :elements => unique!(collect(seeds)))
return Omega
Expand Down Expand Up @@ -117,7 +118,7 @@
## general method with explicit action function

"""
gset(G::Union{GAPGroup, FinGenAbGroup}[, fun::Function], seeds, closed::Bool = false)
gset(G::Union{GAPGroup, FinGenAbGroup}[, fun::Function], seeds, closed::Bool = false, check::Bool = true)

Return the G-set `Omega` that consists of the closure of the seeds `seeds`
under the action of `G` defined by `fun`.
Expand All @@ -130,6 +131,9 @@
for example, if `G` is a `PermGroup` and `seeds` is a `Vector{T}`
where `T` is one of `Int`, `Set{Int}`, `Vector{Int}`.

If `check` is set to `false` then it is *not* checked whether the entries
of `seeds` are valid as the first argument of `fun`.

If `closed` is set to `true` then `seeds` is assumed to be closed
under the action of `G`.
In this case, `collect(Omega)` is guaranteed to be equal to `collect(seeds)`;
Expand All @@ -151,8 +155,8 @@
6
```
"""
function gset(G::Union{GAPGroup, FinGenAbGroup}, fun::Function, seeds; closed::Bool = false)
return GSetByElements(G, fun, seeds; closed = closed)
function gset(G::Union{GAPGroup, FinGenAbGroup}, fun::Function, seeds; closed::Bool = false, check::Bool = true)
return GSetByElements(G, fun, seeds; closed = closed, check = check)
end


Expand All @@ -169,47 +173,47 @@

## natural action of permutations on positive integers
function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) where T<:IntegerUnion
return GSetByElements(G, ^, Omega; closed = closed)
return GSetByElements(G, ^, Omega; closed = closed, check = false)
end

## action of permutations on sets of positive integers
function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) where T<:Set{T2} where T2<:IntegerUnion
return GSetByElements(G, on_sets, Omega; closed = closed)
return GSetByElements(G, on_sets, Omega; closed = closed, check = false)
end

## action of permutations on vectors of positive integers
function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) where T<:Vector{T2} where T2<:IntegerUnion
return GSetByElements(G, on_tuples, Omega; closed = closed)
return GSetByElements(G, on_tuples, Omega; closed = closed, check = false)
end

## action of permutations on tuples of positive integers
function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) where T<:Tuple{T2,Vararg{T2}} where T2<:IntegerUnion
return GSetByElements(G, on_tuples, Omega; closed = closed)
return GSetByElements(G, on_tuples, Omega; closed = closed, check = false)
end

## action of matrices on vectors via right multiplication
function gset_by_type(G::MatrixGroup{E, M}, Omega, ::Type{AbstractAlgebra.Generic.FreeModuleElem{E}}; closed::Bool = false) where E where M
return GSetByElements(G, *, Omega; closed = closed)
return GSetByElements(G, *, Omega; closed = closed, check = false)
end

## action of matrices on sets of vectors via right multiplication
function gset_by_type(G::MatrixGroup{E, M}, Omega, ::Type{T}; closed::Bool = false) where T <: Set{AbstractAlgebra.Generic.FreeModuleElem{E}} where E where M
return GSetByElements(G, on_sets, Omega; closed = closed)
return GSetByElements(G, on_sets, Omega; closed = closed, check = false)
end

## action of matrices on vectors of vectors via right multiplication
function gset_by_type(G::MatrixGroup{E, M}, Omega, ::Type{T}; closed::Bool = false) where T <: Vector{AbstractAlgebra.Generic.FreeModuleElem{E}} where E where M
return GSetByElements(G, on_tuples, Omega; closed = closed)
return GSetByElements(G, on_tuples, Omega; closed = closed, check = false)
end

## action of matrices on subspaces via right multiplication
function gset_by_type(G::MatrixGroup{E, M}, Omega, ::Type{T}; closed::Bool = false) where T <: AbstractAlgebra.Generic.Submodule{E} where E where M
return GSetByElements(G, ^, Omega; closed = closed)
return GSetByElements(G, ^, Omega; closed = closed, check = false)
end

## action of matrices on polynomials via `on_indeterminates`
function gset_by_type(G::MatrixGroup{E, M}, Omega, ::Type{T}; closed::Bool = false) where T <: MPolyRingElem{E} where E where M
return GSetByElements(G, on_indeterminates, Omega; closed = closed)
return GSetByElements(G, on_indeterminates, Omega; closed = closed, check = false)
end

## (add more such actions: on sets of sets, on sets of tuples, ...)
Expand Down Expand Up @@ -738,8 +742,8 @@
return action_homomorphism(gset_by_type(G, Omega, eltype(Omega); closed = true))
end

function action_homomorphism(G::PermGroup, fun::Function, Omega)
return action_homomorphism(GSetByElements(G, fun, Omega, closed = true))
function action_homomorphism(G::PermGroup, fun::Function, Omega; check = true)
return action_homomorphism(GSetByElements(G, fun, Omega, closed = true, check = check))

Check warning on line 746 in src/Groups/gsets.jl

View check run for this annotation

Codecov / codecov/patch

src/Groups/gsets.jl#L745-L746

Added lines #L745 - L746 were not covered by tests
end


Expand Down
1 change: 1 addition & 0 deletions test/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
@test ! is_transitive(Omega)
@test ! is_regular(Omega)
@test ! is_semiregular(Omega)
@test_throws ArgumentError gset(G, permuted, omega)

R, x = polynomial_ring(QQ, [:x1, :x2, :x3]);
f = x[1]*x[2] + x[2]*x[3]
Expand Down
Loading