Skip to content

Commit

Permalink
Resolve some issues of unbound type parameters (#3060)
Browse files Browse the repository at this point in the history
* Track number of unbound type parameters
  • Loading branch information
lgoettgens authored Jan 4, 2024
1 parent b702670 commit 5c58698
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 46 deletions.
4 changes: 2 additions & 2 deletions docs/src/Groups/subgroups.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ frattini_subgroup
socle
solvable_radical
pcore(G::GAPGroup, p::IntegerUnion)
intersect(V::T...) where T<:GAPGroup
intersect(::T, V::T...) where T<:GAPGroup
```

The following functions return a vector of subgroups.
Expand Down Expand Up @@ -122,5 +122,5 @@ right_acting_group(C::GroupDoubleCoset)
representative(C::GroupDoubleCoset)
order(C::Union{GroupCoset,GroupDoubleCoset})
Base.rand(C::Union{GroupCoset,GroupDoubleCoset})
intersect(V::AbstractVector{Union{T, GroupCoset, GroupDoubleCoset}}) where T <: GAPGroup
intersect(V::AbstractVector{Union{<: GAPGroup, GroupCoset, GroupDoubleCoset}})
```
6 changes: 5 additions & 1 deletion experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,11 @@ end

struct CoChain{N, G, M}
C::GModule
d::Dict{NTuple{N, G}, M}
d::Dict{NTuple{N, G}, M}

function CoChain{N, G, M}(C::GModule, d::Dict{NTuple{N, G}, M}) where {N, G, M}
return new{N, G, M}(C, d)
end
end

function Base.show(io::IO, C::CoChain{N}) where {N}
Expand Down
4 changes: 2 additions & 2 deletions src/Groups/cosets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,12 @@ function Base.iterate(G::GroupDoubleCoset, state)
end

"""
intersect(V::AbstractVector{Union{T, GroupCoset, GroupDoubleCoset}}) where T <: GAPGroup
intersect(V::AbstractVector{Union{<: GAPGroup, GroupCoset, GroupDoubleCoset}})
Return a vector containing all elements belonging to all groups and cosets
in `V`.
"""
function intersect(V::AbstractVector{Union{T, GroupCoset, GroupDoubleCoset}}) where T <: GAPGroup
function intersect(V::AbstractVector{Union{<: GAPGroup, GroupCoset, GroupDoubleCoset}})
if V[1] isa GAPGroup
G = V[1]
else
Expand Down
4 changes: 2 additions & 2 deletions src/Groups/directproducts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ end

# return the element (L[1],L[2],...) in W
function (W::WreathProductGroup)(
L::Union{GAPGroupElem{T},GAPGroupElem{PermGroup}}...
) where {T<:GAPGroup}
L::Union{GAPGroupElem{<:GAPGroup},GAPGroupElem{PermGroup}}...
)
d = GAP.Globals.NrMovedPoints(GAPWrap.Image(W.a.map))
@req length(L) == d + 1 "Wrong number of arguments"
for i in 1:d
Expand Down
2 changes: 1 addition & 1 deletion src/Groups/gsets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) wher
end

## action of permutations on tuples of positive integers
function gset_by_type(G::PermGroup, Omega, ::Type{T}; closed::Bool = false) where T<:Tuple{Vararg{T2}} where T2<:IntegerUnion
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)
end

Expand Down
4 changes: 2 additions & 2 deletions src/Groups/matrices/MatGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function matrix_group(F::Ring, m::Int, V::AbstractVector{T}; check::Bool=true) w
return G
end

matrix_group(R::Ring, m::Int, V::T...; check::Bool=true) where T<:Union{MatElem,MatrixGroupElem} = matrix_group(R, m, collect(V); check)
matrix_group(R::Ring, m::Int, V::Union{MatElem,MatrixGroupElem}...; check::Bool=true) = matrix_group(R, m, collect(V); check)

matrix_group(V::AbstractVector{T}; check::Bool=true) where T<:Union{MatElem,MatrixGroupElem} = matrix_group(base_ring(V[1]), nrows(V[1]), V; check)

matrix_group(V::T...; check::Bool=true) where T<:Union{MatElem,MatrixGroupElem} = matrix_group(collect(V); check)
matrix_group(V::Union{MatElem,MatrixGroupElem}...; check::Bool=true) = matrix_group(collect(V); check)

# For `general_linear_group` etc. the degree comes first, so we should also provide that option
matrix_group(m::Int, R::Ring) = matrix_group(R, m)
Expand Down
30 changes: 15 additions & 15 deletions src/Groups/perm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,26 +281,26 @@ true
At the moment, the input vectors of the function `cperm` need not be disjoint.
"""
function cperm(L::AbstractVector{T}...) where T <: IntegerUnion
if length(L)==0
return one(symmetric_group(1))
else
return prod([PermGroupElem(symmetric_group(maximum(y)), GAPWrap.CycleFromList(GAP.Obj([Int(k) for k in y]))) for y in L])
#TODO: better create the product of GAP permutations?
end
function cperm()
return one(symmetric_group(1))
end

function cperm(L1::AbstractVector{T}, L::AbstractVector{T}...) where T <: IntegerUnion
return prod([PermGroupElem(symmetric_group(maximum(y)), GAPWrap.CycleFromList(GAP.Obj([Int(k) for k in y]))) for y in [L1, L...]])
#TODO: better create the product of GAP permutations?
end

# cperm stays for "cycle permutation", but we can change name if we want
# takes as input a list of vectors (not necessarily disjoint)
# WARNING: we allow e.g. PermList([2,3,1,4,5,6]) in Sym(3)
function cperm(g::PermGroup,L::AbstractVector{T}...) where T <: IntegerUnion
if length(L)==0
return one(g)
else
x=prod(y -> GAPWrap.CycleFromList(GAP.Obj([Int(k) for k in y])), L)
@req x in g.X "the element does not embed in the group"
return PermGroupElem(g, x)
end
function cperm(g::PermGroup)
return one(g)
end

function cperm(g::PermGroup, L1::AbstractVector{T}, L::AbstractVector{T}...) where T <: IntegerUnion
x = prod(y -> GAPWrap.CycleFromList(GAP.Obj([Int(k) for k in y])), [L1, L...])
@req x in g.X "the element does not embed in the group"
return PermGroupElem(g, x)
end

function cperm(L::Vector{Vector{T}}) where T <: IntegerUnion
Expand Down
10 changes: 2 additions & 8 deletions src/Groups/sub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,8 @@ If `V` is $[ G_1, G_2, \ldots, G_n ]$,
return the intersection $K$ of the groups $G_1, G_2, \ldots, G_n$,
together with the embeddings of $K into $G_i$.
"""
function intersect(V::T...) where T<:GAPGroup
L = GapObj([G.X for G in V])
K = GAP.Globals.Intersection(L)::GapObj
Embds = [_as_subgroup(G, K)[2] for G in V]
K = _as_subgroup(V[1], K)[1]
Arr = Tuple(vcat([K],Embds))
return Arr
function intersect(G1::T, V::T...) where T<:GAPGroup
return intersect([G1, V...])
end

function intersect(V::AbstractVector{T}) where T<:GAPGroup
Expand All @@ -1184,4 +1179,3 @@ function intersect(V::AbstractVector{T}) where T<:GAPGroup
Arr = Tuple(vcat([K],Embds))
return Arr
end
#T why duplicate this code?
8 changes: 5 additions & 3 deletions src/InvariantTheory/invariant_rings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ function invariant_ring(R::MPolyDecRing, M::Vector{<: MatrixElem})
return invariant_ring(R, matrix_group([change_base_ring(K, g) for g in M]))
end

invariant_ring(matrices::MatrixElem{T}...) where {T} = invariant_ring(collect(matrices))
function invariant_ring(m::MatrixElem{T}, ms::MatrixElem{T}...) where {T}
return invariant_ring([m, ms...])
end

function invariant_ring(R::MPolyDecRing, matrices::MatrixElem{T}...) where {T}
return invariant_ring(R, collect(matrices))
function invariant_ring(R::MPolyDecRing, m::MatrixElem{T}, ms::MatrixElem{T}...) where {T}
return invariant_ring(R, [m, ms...])
end

function invariant_ring(K::Field, M::Vector{<: MatrixElem})
Expand Down
3 changes: 2 additions & 1 deletion src/PolyhedralGeometry/Cone/standard_constructions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ julia> c == ctt
true
```
"""
function transform(C::Cone{T}, A::Union{AbstractMatrix{<:Union{Number, FieldElem}}, MatElem{U}}) where {T<:scalar_types, U<:FieldElem}
function transform(C::Cone{T}, A::Union{AbstractMatrix{<:Union{Number, FieldElem}}, MatElem{<:FieldElem}}) where {T<:scalar_types}
@assert ambient_dim(C) == nrows(A) "Incompatible dimension of cone and transformation matrix"
@assert nrows(A) == ncols(A) "Transformation matrix must be square"
@assert Polymake.common.rank(A) == nrows(A) "Transformation matrix must have full rank."
return _transform(C, A)
end

function _transform(C::Cone{T}, A::AbstractMatrix{<:FieldElem}) where T<:scalar_types
U, f = _promote_scalar_field(A)
V, g = _promote_scalar_field(coefficient_field(C), f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,20 @@ end
Get the image of a fan `F` under the matrix `A`. The default is to check
whether the images of the maximal cones really form a fan.
"""
function transform(F::_FanLikeType, A::Union{AbstractMatrix{<:Union{Number, FieldElem}}, MatElem{U}}; check=true) where {U<:FieldElem}
function transform(F::_FanLikeType, A::Union{AbstractMatrix{<:Union{Number, FieldElem}}, MatElem{<:FieldElem}}; check::Bool=true)
@req ncols(A) == ambient_dim(F) "Incompatible dimension of fan and transformation matrix"
OT = _scalar_type_to_polymake(_get_scalar_type(F))
return _transform(F, Polymake.Matrix{OT}(A); check=check)
return _transform(F, Polymake.Matrix{OT}(A); check)
end
function _transform(F::_FanLikeType, A::Polymake.Matrix; check)

function _transform(F::_FanLikeType, A::Polymake.Matrix; check::Bool)
OT = _scalar_type_to_polymake(_get_scalar_type(F))
FT = typeof(F)
R = pm_object(F).RAYS * transpose(A)
L = pm_object(F).LINEALITY_SPACE * transpose(A)
MC = pm_object(F).MAXIMAL_CONES
opt = Polymake.OptionSet(Dict(["lineality_space" => L]))
if(check)
if check
result = Polymake.fan.check_fan(R, MC, opt)
return FT(result, coefficient_field(F))
else
Expand Down
2 changes: 1 addition & 1 deletion src/PolyhedralGeometry/Polyhedron/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ x_3 <= 1
"""
facets(
as::Type{T}, P::Polyhedron{S}
) where {R,S<:scalar_types,T<:Union{AffineHalfspace{S},Pair{R,S},Polyhedron{S}}} =
) where {S<:scalar_types,T<:Union{AffineHalfspace{S},Pair{R,S} where R,Polyhedron{S}}} =
SubObjectIterator{as}(P, _facet_polyhedron, nfacets(P))

function _facet_polyhedron(
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/PBWAlgebraQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Map defined by a julia-function with inverse
For reasons of efficiency, it is recommended to use the built-in constructor `exterior_algebra` when working with
exterior algebras in OSCAR.
"""
function quo(Q::PBWAlgRing, I::PBWAlgIdeal; SpecialImpl::Union{Nothing, Singular.PluralRing{S}} = nothing) where {S}
function quo(Q::PBWAlgRing, I::PBWAlgIdeal; SpecialImpl::Union{Nothing, Singular.PluralRing} = nothing)
@assert (Q == base_ring(I));
### No idea how to check whether SpecialImpl is sane!
#??? Check if I is ideal of squares of gens then produce ExtAlg???
Expand Down
5 changes: 2 additions & 3 deletions src/Serialization/polymake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ const polymake2OscarTypes = Dict{String, Type}([
@register_serialization_type Polymake.BigObjectAllocated "Polymake.BigObject" uses_id

function load_from_polymake(::Type{T}, jsondict::Dict{Symbol, Any}) where {
S<:scalar_types,
T<:Union{Cone{S}, Polyhedron{S}, PolyhedralFan{S},
PolyhedralComplex{S}, SubdivisionOfPoints{S}, SimplicialComplex}}
T<:Union{Cone{<:scalar_types}, Polyhedron{<:scalar_types}, PolyhedralFan{<:scalar_types},
PolyhedralComplex{<:scalar_types}, SubdivisionOfPoints{<:scalar_types}, SimplicialComplex}}

inner_object = Polymake.call_function(:common, :deserialize_json_string, json(jsondict))
return T(inner_object)
Expand Down
1 change: 1 addition & 0 deletions test/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ using Aqua
unbound_args=false, # TODO: fix unbound type parameters
piracies=false, # TODO: check the reported methods to be moved upstream
)
@test length(Aqua.detect_unbound_args_recursively(Oscar)) <= 16
end

0 comments on commit 5c58698

Please sign in to comment.