Skip to content

Commit

Permalink
Replace many uses of G.X by GapObj(X) (#3671)
Browse files Browse the repository at this point in the history
* Add GapObj / julia_to_gap conversion methods for more types

Specifically, for
- MatrixGroup
- MatrixGroupElem
- SesquilinearForm
- GroupCoset
- GroupDoubleCoset
- GAPGroupConjClass

I left out SubgroupTransversal because there are additional
semantics on the Julia side invisible to the GAP object, so the
"conversion" is not always quite safe.

Also did nothing for GAPGroupClassFunction as there is no obvious
"free" conversion available there. We could still add a method,
but I'll leave that to a potential future PR.

* Export GapObj

* GAP: replace many uses of G.X by GapObj(X)

... so that ultimately we can refactor the underpinnings of GAPGroup etc.

* Remove an obsolete Base.getproperty method

* Simplify some code
  • Loading branch information
fingolfin committed May 2, 2024
1 parent 7517170 commit 00786b1
Show file tree
Hide file tree
Showing 39 changed files with 377 additions and 350 deletions.
2 changes: 1 addition & 1 deletion examples/H2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module H2_G_QmodZ_mod
using Oscar

function schur_cover(G::Oscar.GAPGroup)
f = GAP.Globals.EpimorphismSchurCover(G.X)
f = GAP.Globals.EpimorphismSchurCover(GapObj(G))
k = GAP.Globals.Source(f)
S = FPGroup(k)
return S, GAPGroupHomomorphism(S, G, f)
Expand Down
4 changes: 2 additions & 2 deletions experimental/GModule/Brueckner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function reps(K, G::Oscar.GAPGroup)
return [gmodule(F, G, typeof(h)[h for i = gens(G)])]
end

pcgs = GAP.Globals.Pcgs(G.X)
pcgs = GAP.Globals.Pcgs(GapObj(G))
pcgs == GAP.Globals.fail && error("the group is not polycyclic")

gG = [Oscar.group_element(G, x) for x = pcgs]
Expand Down Expand Up @@ -316,7 +316,7 @@ function lift(C::GModule, mp::Map)
GG, GGinj, GGpro, GMtoGG = Oscar.GrpCoh.extension(PcGroup, z(h))

s = hom(D, K, [zero(K) for i=1:ngens(D)])
gns = [GMtoGG([x for x = GAP.Globals.ExtRepOfObj(h.X)], zero(M)) for h = gens(N)]
gns = [GMtoGG([x for x = GAP.Globals.ExtRepOfObj(GapObj(h))], zero(M)) for h = gens(N)]
gns = [map_word(mp(g), gns, init = one(GG)) for g = gens(G)]

rel = [map_word(r, gns, init = one(GG)) for r = relators(G)]
Expand Down
50 changes: 25 additions & 25 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ end
The relations defining 'F' as an array of pairs.
"""
function _relations_by_generators(G::Oscar.GAPGroup)
f = GAPWrap.IsomorphismFpGroupByGenerators(G.X, GAPWrap.GeneratorsOfGroup(G.X))
f = GAPWrap.IsomorphismFpGroupByGenerators(GapObj(G), GAPWrap.GeneratorsOfGroup(GapObj(G)))
@req f != GAP.Globals.fail "Could not convert group into a group of type FPGroup"
H = FPGroup(GAPWrap.Image(f))
return relations(H)
Expand All @@ -546,8 +546,8 @@ end

function Oscar.relations(G::PcGroup)
# Call `GAPWrap.IsomorphismFpGroupByPcgs` only if `gens(G)` is a pcgs.
Ggens = GAPWrap.GeneratorsOfGroup(G.X)
Gpcgs = GAPWrap.Pcgs(G.X)
Ggens = GAPWrap.GeneratorsOfGroup(GapObj(G))
Gpcgs = GAPWrap.Pcgs(GapObj(G))
Ggens == Gpcgs || return _relations_by_generators(G)
f = GAPWrap.IsomorphismFpGroupByPcgs(Gpcgs, GAP.Obj("g"))
@req f != GAP.Globals.fail "Could not convert group into a group of type FPGroup"
Expand Down Expand Up @@ -891,14 +891,14 @@ end
function confluent_fp_group_pc(G::Oscar.GAPGroup)
g = isomorphism(PcGroup, G)
P = codomain(g)
f = GAPWrap.IsomorphismFpGroupByPcgs(GAP.Globals.FamilyPcgs(P.X), GAP.Obj("g"))
f = GAPWrap.IsomorphismFpGroupByPcgs(GAP.Globals.FamilyPcgs(GapObj(P)), GAP.Obj("g"))
@req f != GAP.Globals.fail "Could not convert group into a group of type FPGroup"
H = FPGroup(GAPWrap.Image(f))
R = relations(H)
ru = Vector{Tuple{Vector{Int}, Vector{Int}}}()
for r = R
push!(ru, (map(Int, GAP.Globals.LetterRepAssocWord(r[1].X)),
map(Int, GAP.Globals.LetterRepAssocWord(r[2].X))))
push!(ru, (map(Int, GAP.Globals.LetterRepAssocWord(GapObj(r[1]))),
map(Int, GAP.Globals.LetterRepAssocWord(GapObj(r[2])))))
end
i = 0
ex = []
Expand Down Expand Up @@ -932,7 +932,7 @@ relations given as pairs of words.
Return the new group, the isomorphism and the confluent relations.
"""
function confluent_fp_group(G::Oscar.GAPGroup)
C = GAP.Globals.ConfluentMonoidPresentationForGroup(G.X)
C = GAP.Globals.ConfluentMonoidPresentationForGroup(GapObj(G))
#has different generators than G! So the action will have to
#be adjusted to those words. I do not know if a RWS (Confluent) can
#just be changed...
Expand Down Expand Up @@ -1822,7 +1822,7 @@ function pc_group_with_isomorphism(M::FinGenAbGroup; refine::Bool = true)
set_power!(C, i, r)
end
B = pc_group(C)
FB = GAP.Globals.FamilyObj(GAP.Globals.Identity(B.X))
FB = GAP.Globals.FamilyObj(GAP.Globals.Identity(GapObj(B)))

Julia_to_gap = function(a::FinGenAbGroupElem)
r = ZZRingElem[]
Expand Down Expand Up @@ -1851,7 +1851,7 @@ function pc_group_with_isomorphism(M::FinGenAbGroup; refine::Bool = true)
return B, MapFromFunc(
codomain(mM), B,
y->PcGroupElem(B, Julia_to_gap(preimage(mM, y))),
x->image(mM, gap_to_julia(x.X)))
x->image(mM, gap_to_julia(GapObj(x))))
end

function pc_group_with_isomorphism(M::AbstractAlgebra.FPModule{<:FinFieldElem}; refine::Bool = true)
Expand All @@ -1860,9 +1860,9 @@ function pc_group_with_isomorphism(M::AbstractAlgebra.FPModule{<:FinFieldElem};

G = free_group(degree(k)*dim(M))

C = GAP.Globals.CombinatorialCollector(G.X,
C = GAP.Globals.CombinatorialCollector(GapObj(G),
GAP.Obj([p for i=1:ngens(G)], recursive = true))
F = GAP.Globals.FamilyObj(GAP.Globals.Identity(G.X))
F = GAP.Globals.FamilyObj(GAP.Globals.Identity(GapObj(G)))

# Note that we have specified all relative orders as `p`.
# Missing commutator and power relators are interpreted as trivial,
Expand All @@ -1871,7 +1871,7 @@ function pc_group_with_isomorphism(M::AbstractAlgebra.FPModule{<:FinFieldElem};
@assert is_abelian(B)
@assert order(B) == order(M)

FB = GAP.Globals.FamilyObj(GAP.Globals.Identity(B.X))
FB = GAP.Globals.FamilyObj(GAP.Globals.Identity(GapObj(B)))

function Julia_to_gap(a::AbstractAlgebra.FPModuleElem{<:Union{fpFieldElem, FpFieldElem, FqFieldElem}})
F = base_ring(parent(a))
Expand Down Expand Up @@ -1922,12 +1922,12 @@ function pc_group_with_isomorphism(M::AbstractAlgebra.FPModule{<:FinFieldElem};
return B, MapFromFunc(
M, B,
y->PcGroupElem(B, Julia_to_gap(y)),
x->gap_to_julia(x.X))
x->gap_to_julia(GapObj(x)))
end


function underlying_word(g::FPGroupElem)
return FPGroupElem(free_group(parent(g)), GAPWrap.UnderlyingElement(g.X))
return FPGroupElem(free_group(parent(g)), GAPWrap.UnderlyingElement(GapObj(g)))
end

"""
Expand Down Expand Up @@ -2007,18 +2007,18 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
fM, mfM = pc_group_with_isomorphism(M)

N = free_group(ngens(G) + ngens(fM))
Gp = GAP.Globals.Pcgs(G.X)
Gp = GAP.Globals.Pcgs(GapObj(G))
@assert length(Gp) == ngens(G)
# @assert all(x->Gp[x] == gen(G, x).X, 1:ngens(G))
# @assert all(x->Gp[x] == GapObj(gen(G, x)), 1:ngens(G))
Go = GAP.Globals.RelativeOrders(Gp)

Mp = GAP.Globals.Pcgs(fM.X)
Mp = GAP.Globals.Pcgs(GapObj(fM))
@assert length(Mp) == ngens(fM) == ngens(M)
# @assert all(x->Mp[x] == gen(fM, x).X, 1:ngens(M))
# @assert all(x->Mp[x] == GapObj(gen(fM, x)), 1:ngens(M))
Mo = GAP.Globals.RelativeOrders(Mp)

CN = GAP.Globals.SingleCollector(N.X, GAP.Globals.Concatenation(Go, Mo))
FN = GAP.Globals.FamilyObj(N[1].X)
CN = GAP.Globals.SingleCollector(GapObj(N), GAP.Globals.Concatenation(Go, Mo))
FN = GAP.Globals.FamilyObj(GapObj(N[1]))

for i=1:ngens(fM)
lp = deepcopy(GAPWrap.ExtRepOfObj(Mp[i]^Mo[i]))
Expand All @@ -2039,7 +2039,7 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
end

fMtoN = function(x)
lp = deepcopy(GAPWrap.ExtRepOfObj(x.X))
lp = deepcopy(GAPWrap.ExtRepOfObj(GapObj(x)))
for k=1:2:length(lp)
@assert lp[k] > 0
lp[k] += ngens(G)
Expand Down Expand Up @@ -2110,7 +2110,7 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
# s = GAP.Globals.GapInputPcGroup(z, GAP.Obj("Z"))
# @show GAP.gap_to_julia(s)
Q = PcGroup(GAP.Globals.GroupByRws(CN))
fQ = GAP.Globals.FamilyObj(one(Q).X)
fQ = GAP.Globals.FamilyObj(GapObj(one(Q)))
mQ = hom(N, Q, gens(N), gens(Q))

@assert ngens(Q) == ngens(N)
Expand All @@ -2125,7 +2125,7 @@ function extension(::Type{PcGroup}, c::CoChain{2,<:Oscar.PcGroupElem})
mffM = epimorphism_from_free_group(fM)

function GMtoQ(wg, m)
wm = GAP.gap_to_julia(GAPWrap.ExtRepOfObj(preimage(mffM, mfM(m)).X))
wm = GAP.gap_to_julia(GAPWrap.ExtRepOfObj(GapObj(preimage(mffM, mfM(m)))))
for i=1:2:length(wm)
push!(wg, wm[i]+ngens(G))
push!(wg, wm[i+1])
Expand Down Expand Up @@ -2260,10 +2260,10 @@ end

function all_extensions(M::FinGenAbGroup, G::PermGroup) #the cohomology wants it
A = automorphism_group(M)
l = GAP.Globals.AllHomomorphismClasses(G.X, A.X)
l = GAP.Globals.AllHomomorphismClasses(GapObj(G), GapObj(A))
all_G = []
for i = l
C = gmodule(G, [hom(A(i(g.X))) for g = gens(G)])
C = gmodule(G, [hom(A(i(GapObj(g)))) for g = gens(G)])
append!(all_G, all_extensions(C))
end
return all_G
Expand Down
10 changes: 5 additions & 5 deletions experimental/GModule/GModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ end
function irreducible_modules(k::FinField, G::Oscar.GAPGroup)
h = Oscar.iso_oscar_gap(k)
hi = inv(h)
im = GAP.Globals.IrreducibleRepresentations(G.X, codomain(h))
im = GAP.Globals.IrreducibleRepresentations(GapObj(G), codomain(h))
IM = GModule[]
for m in im
z = map(x->matrix(map(y->map(hi, y), m(x.X))), gens(G))
z = map(x->matrix(map(y->map(hi, y), m(GapObj(x)))), gens(G))
if ngens(G) == 0
F = free_module(k, 0)
zz = typeof(hom(F, F, elem_type(F)[]))[]
Expand All @@ -350,11 +350,11 @@ function irreducible_modules(k::FinField, G::Oscar.GAPGroup)
end

function irreducible_modules(G::Oscar.GAPGroup)
im = GAP.Globals.IrreducibleRepresentations(G.X)
im = GAP.Globals.IrreducibleRepresentations(GapObj(G))
IM = GModule[]
K = abelian_closure(QQ)[1]
for m in im
z = map(x->matrix(map(y->map(K, y), m(x.X))), gens(G))
z = map(x->matrix(map(y->map(K, y), m(GapObj(x)))), gens(G))
if ngens(G) == 0
F = free_module(K, 0)
zz = typeof(hom(F, F, elem_type(F)[]))[]
Expand Down Expand Up @@ -1530,7 +1530,7 @@ end
function Oscar.gmodule(chi::Oscar.GAPGroupClassFunction)
f = GAP.Globals.IrreducibleAffordingRepresentation(chi.values)
K = abelian_closure(QQ)[1]
g = GAP.Globals.List(GAP.Globals.GeneratorsOfGroup(group(chi).X), f)
g = GAP.Globals.List(GAP.Globals.GeneratorsOfGroup(GapObj(group(chi))), f)
z = map(x->matrix(map(y->map(K, y), g[x])), 1:GAP.Globals.Size(g))
F = free_module(K, degree(Int, chi))
return gmodule(group(chi), [hom(F, F, x) for x = z])
Expand Down
2 changes: 1 addition & 1 deletion experimental/GaloisGrp/src/Solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function Oscar.extension_field(f::AbstractAlgebra.Generic.Poly{<:NumFieldElem};
end

function refined_derived_series(G::PermGroup)
s = GAP.Globals.PcSeries(GAP.Globals.Pcgs(G.X))
s = GAP.Globals.PcSeries(GAP.Globals.Pcgs(GapObj(G)))
return Oscar._as_subgroups(G,s)
end

Expand Down
4 changes: 2 additions & 2 deletions experimental/OrthogonalDiscriminants/src/direct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ function od_from_atlas_group(chi::GAPGroupClassFunction)
#T and ask it whether it is abs. irreducible.
l = next_prime(max([x[1] for x in factor(order(tbl))]...))
Gbar, _ = Oscar.isomorphic_group_over_finite_field(G, min_char = Int(l))
GG = Gbar.X
GG = GapObj(Gbar)
else
GG = G.X
GG = GapObj(G)
end
M = GAP.Globals.GModuleByMats(GAP.Globals.GeneratorsOfGroup(GG),
GAP.Globals.FieldOfMatrixGroup(GG))
Expand Down
Loading

0 comments on commit 00786b1

Please sign in to comment.