Skip to content

Commit 7bacc29

Browse files
fingolfinclaude
authored andcommitted
Add PreImagesSet method for semigroup homs by images
GAP 4.17 changes PreImagesSet: a generic method now checks that the argument is a subset of the range and returns the preimage of its intersection with the image. With that method, PreImagesSet no longer signals an error for elements without preimages, which the tests expect, and the error for elements outside the range changes. Install a method for semigroup homomorphisms by images that performs the range check with the package's own error message and otherwise delegates to PreImagesElm, so behaviour is the same with all supported GAP versions. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 2d7b9b7 commit 7bacc29

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎gap/attributes/homomorph.gi‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,20 @@ function(hom, x)
425425
return preim;
426426
end);
427427

428+
# GAP >= 4.17 has a library method for PreImagesSet that returns the preimage
429+
# of the intersection with the image; this method keeps erroring for elements
430+
# without preimages, consistent with the PreImagesElm method above.
431+
InstallMethod(PreImagesSet,
432+
"for a semigroup homom. by images and a list of elements in the range",
433+
[IsSemigroupHomomorphismByImages, IsList],
434+
function(hom, elms)
435+
if not IsSubset(Range(hom), elms) then
436+
ErrorNoReturn("the 2nd argument is not a subset of the range of the ",
437+
"1st argument (semigroup homom. by images)");
438+
fi;
439+
return Union(List(elms, x -> PreImagesElm(hom, x)));
440+
end);
441+
428442
InstallMethod(KernelOfSemigroupHomomorphism, "for a semigroup homomorphism",
429443
[IsSemigroupHomomorphismByImagesOrFunction],
430444
function(hom)

‎tst/standard/attributes/homomorph.tst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ gap> PreImagesElm(hom, 2);
126126
Error, the 2nd argument is not an element of the range of the 1st argument (se\
127127
migroup homom. by images)
128128
gap> PreImagesSet(hom, [2]);
129-
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
130-
Error, no 1st choice method found for `PreImagesSet' on 2 arguments
129+
Error, the 2nd argument is not a subset of the range of the 1st argument (semi\
130+
group homom. by images)
131131
gap> IsSurjective(hom);
132132
true
133133
gap> IsInjective(hom);

0 commit comments

Comments
 (0)