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

Don't use One on collections that are not domains #5155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 7 additions & 6 deletions lib/monoid.gi
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,22 @@ InstallMethod( ViewString,
InstallOtherMethod(MonoidByGenerators, "for a collection",
[IsCollection],
function(gens)
local M, pos;
local M, pos, one;

M := Objectify(NewType(FamilyObj(gens), IsMonoid
and IsAttributeStoringRep), rec());
gens := AsList(gens);

if CanEasilyCompareElements(gens) and IsFinite(gens)
and IsMultiplicativeElementWithOneCollection(gens) then
SetOne(M, One(gens));
pos := Position(gens, One(gens));
one := One(Representative(gens));
SetOne(M, one);
pos := Position(gens, one);
if pos <> fail then
SetGeneratorsOfMagma(M, gens);
if Length(gens) = 1 then # Length(gens) <> 0 since One(gens) in gens
if Length(gens) = 1 then # Length(gens) <> 0 since one in gens
SetIsTrivial(M, true);
elif not IsPartialPermCollection(gens) or One(gens) =
elif not IsPartialPermCollection(gens) or one =
One(gens{Concatenation([1 .. pos - 1], [pos + 1 .. Length(gens)])}) then
# if gens = [PartialPerm([1,2]), PartialPerm([1])], then removing the One
# = gens[1] from this, it is not possible to recreate the semigroup using
Expand All @@ -93,7 +94,7 @@ function(gens)
Remove(gens, pos);
fi;
else
SetGeneratorsOfMagma(M, Concatenation([One(gens)], gens));
SetGeneratorsOfMagma(M, Concatenation([one], gens));
fi;
fi;

Expand Down
9 changes: 5 additions & 4 deletions lib/semigrp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ InstallMethod(SemigroupByGenerators,
"for a collection",
[IsCollection],
function(gens)
local S, pos;
local S, pos, one;

S := Objectify(NewType(FamilyObj(gens), IsSemigroup
and IsAttributeStoringRep), rec());
Expand All @@ -502,12 +502,13 @@ function(gens)
if IsMultiplicativeElementWithOneCollection(gens)
and CanEasilyCompareElements(gens)
and IsFinite(gens) then
pos := Position(gens, One(gens));
one := One(Representative(gens));
pos := Position(gens, one);
if pos <> fail then
SetFilterObj(S, IsMonoid);
if Length(gens) = 1 then # Length(gens) <> 0 since One(gens) in gens
if Length(gens) = 1 then # Length(gens) <> 0 since one in gens
SetIsTrivial(S, true);
elif not IsPartialPermCollection(gens) or One(gens) =
elif not IsPartialPermCollection(gens) or one =
One(gens{Concatenation([1 .. pos - 1], [pos + 1 .. Length(gens)])}) then
# if gens = [PartialPerm([1, 2]), PartialPerm([1])], then removing the One
# = gens[1] from this, it is not possible to recreate the semigroup using
Expand Down
4 changes: 3 additions & 1 deletion tst/testinstall/semipperm.tst
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ true
# Test IsomorphismPartialPermMonoid for a partial perm semigroup
gap> S := Semigroup(PartialPerm([2], [2]), PartialPerm([1], [1]));;
gap> IsomorphismPartialPermMonoid(S);
Error, the argument must be a semigroup with a multiplicative neutral element
MappingByFunction( <partial perm monoid of rank 2 with 2 generators>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense I’m afraid, the semigroup generated by the two partial perms given is not a monoid, and I think that with the changes in this pr it wouldn’t be the case that the return value of One was a multiplicative neutral element. I’m not sure what the motivation behind this is, and I’m pretty sure that making this change will badly break lots of the code for Semigroups

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case it helps others reviewing, the identity returned by One is not the identity for the entire family of partial perms, but only for those partial perms with the same support. This is very different from the permutation case where all permutations have the same support (all positive integers). This means that One would need to be called on the list or the domain generated by the list, but this is the function that creates that domain, so seems hard to get right without calling it on a list.

gap> gens := [ PartialPerm([2], [2]), PartialPerm([1], [1]) ];
[ <identity partial perm on [ 2 ]>, <identity partial perm on [ 1 ]> ]
gap> One(gens);
<identity partial perm on [ 1, 2 ]>
gap> One(Representative(gens));
<identity partial perm on [ 2 ]>
gap> One(gens[1]);
<identity partial perm on [ 2 ]>

<partial perm monoid of rank 2 with 2 generators>
, function( object ) ... end, function( object ) ... end )
gap> S := Semigroup(PartialPerm([2, 1]));;
gap> IsomorphismPartialPermMonoid(S);;
gap> IsMonoid(Range(last));
Expand Down