From 089f0bd01a0491a647ee36ca0e053a9901a126be Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 13 Sep 2026 10:02:39 +0200 Subject: [PATCH] Use NC variants of PreImages operations GAP 4.17 splits PreImagesSet and PreImagesRepresentative into checked operations and unchecked NC variants, and its library calls only the NC variants. Install the geometry morphism method for PreImagesSetNC, so that library calls find it, and keep a PreImagesSet method delegating to it: the generic checked method fails its IsSubset test on geometry morphisms. Call the NC variants internally where the argument is known to lie in the image (stabiliser generators under action homomorphisms, the BLT-set under the duality), avoiding the range and image membership tests. For GAP < 4.17, init.g binds the NC names to the checked operations. Assisted-by: Claude Code (Opus 5) --- init.g | 16 ++++++++++++++++ lib/gpolygons.gi | 4 ++-- lib/morphisms.gi | 14 ++++++++++++-- lib/orbits-stabilisers.gi | 4 ++-- tst/bugfix.tst | 8 ++++++++ 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/init.g b/init.g index 4801060..2e70fd9 100644 --- a/init.g +++ b/init.g @@ -28,6 +28,22 @@ if not IsBound(MultVector) then DeclareSynonym( "MultVector", MultRowVector ); fi; +# +# GAP >= 4.17 has unchecked NC variants of the PreImages operations +# +if not IsBound( PreImagesNC ) then + BindGlobal( "PreImagesNC", PreImages ); +fi; +if not IsBound( PreImagesElmNC ) then + BindGlobal( "PreImagesElmNC", PreImagesElm ); +fi; +if not IsBound( PreImagesSetNC ) then + BindGlobal( "PreImagesSetNC", PreImagesSet ); +fi; +if not IsBound( PreImagesRepresentativeNC ) then + BindGlobal( "PreImagesRepresentativeNC", PreImagesRepresentative ); +fi; + ReadPackage("fining","lib/geometry.gd"); ReadPackage("fining","lib/liegeometry.gd"); diff --git a/lib/gpolygons.gi b/lib/gpolygons.gi index c8014fc..69989da 100644 --- a/lib/gpolygons.gi +++ b/lib/gpolygons.gi @@ -4020,7 +4020,7 @@ InstallMethod( EGQByBLTSet, [0,0,0,1,0,0],[0,0,0,0,1,0]]*One(f)); q4qcanonical := Range(duality)!.geometry; iso := IsomorphismPolarSpaces(q4q, q4qcanonical); - bltdual := PreImagesSet(duality, ImagesSet(iso, blt)); + bltdual := PreImagesSetNC(duality, ImagesSet(iso, blt)); Info(InfoFinInG, 1, "Now embedding dual BLT-set into W(5,q)..."); @@ -4301,7 +4301,7 @@ InstallMethod( FlockGQByqClan, [ IsqClanObj ], imgs := Filtered([1..Size(omega)], x -> omega[x] in blt);; stabblt := Stabilizer(Image(hom), imgs, OnSets); gens := GeneratorsOfGroup(stabblt); - gens := List(gens, x -> PreImagesRepresentative(hom, x)); + gens := List(gens, x -> PreImagesRepresentativeNC(hom, x)); stabblt := GroupWithGenerators(gens); Info(InfoFinInG, 1, "..computed stabiliser of BLT set"); diff --git a/lib/morphisms.gi b/lib/morphisms.gi index bbc585e..77dc81d 100644 --- a/lib/morphisms.gi +++ b/lib/morphisms.gi @@ -204,15 +204,25 @@ InstallOtherMethod( PreImageElm, # CHECKED 27/09/11 jdb ############################################################################# -#O PreImagesSet( , ) +#O PreImagesSetNC( , ) ## -InstallOtherMethod( PreImagesSet, +InstallOtherMethod( PreImagesSetNC, "for a geometry morphism and an element of an incidence structure", [IsGeometryMorphism, IsElementOfIncidenceStructureCollection], function(em, x) return List(x, t -> em!.prefun(t)); end ); +# The generic PreImagesSet fails its IsSubset( Range( em ), x ) check for +# geometry morphisms. Without PreImagesSetNC in GAP, both names denote the +# same operation, see init.g. +if not IsIdenticalObj( PreImagesSet, PreImagesSetNC ) then + InstallOtherMethod( PreImagesSet, + "for a geometry morphism and an element of an incidence structure", + [IsGeometryMorphism, IsElementOfIncidenceStructureCollection], + PreImagesSetNC ); +fi; + ########################################################## ## User methods for the "natural geometry morphisms" ########################################################## diff --git a/lib/orbits-stabilisers.gi b/lib/orbits-stabilisers.gi index e6174af..8d0f753 100644 --- a/lib/orbits-stabilisers.gi +++ b/lib/orbits-stabilisers.gi @@ -411,7 +411,7 @@ InstallMethod( FiningStabiliserPerm, [IsProjectiveGroupWithFrob, IsElementOfInci nr:=Position(enum,el); stab:=Stabilizer(Image(hom),nr); gens:=GeneratorsOfGroup(stab);; - gens:=List(gens,x->PreImagesRepresentative(hom,x)); + gens:=List(gens,x->PreImagesRepresentativeNC(hom,x)); stab:=GroupWithGenerators(gens); return stab; end ); @@ -433,7 +433,7 @@ InstallMethod( FiningStabiliserPerm2, stab:=Stab(im,nr,OnPoints,rec( DoEstimate := size )).stab; #stab:=Stabiliser(Image(hom),nr); gens:=GeneratorsOfGroup(stab);; - gens:=List(gens,x->PreImagesRepresentative(hom,x)); + gens:=List(gens,x->PreImagesRepresentativeNC(hom,x)); stab:=GroupWithGenerators(gens); return stab; end ); diff --git a/tst/bugfix.tst b/tst/bugfix.tst index 413e85e..75a7986 100644 --- a/tst/bugfix.tst +++ b/tst/bugfix.tst @@ -20,5 +20,13 @@ gap> ElationOfProjectiveSpace(l, p, q); gap> SingerCycleCollineation(2, 2^6); < a collineation: , F^0> +# GAP >= 4.17 calls PreImagesSetNC internally +gap> d := NaturalDuality(SymplecticSpace(3, 3));; +gap> pts := AsList(Points(Range(d)!.geometry)){[1..3]};; +gap> PreImagesSetNC(d, pts) = List(pts, x -> PreImageElm(d, x)); +true +gap> PreImagesSet(d, pts) = PreImagesSetNC(d, pts); +true + # gap> STOP_TEST("bugfix.tst", 1 );