Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/addmagma.gi
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ InstallGlobalFunction( SubadditiveMagmaNC, function( M, gens )
if IsEmpty( gens ) then
K:= NewType( FamilyObj(M),
IsAdditiveMagma
and IsTrivial
and IsEmpty
and IsAttributeStoringRep );
S:= Objectify( K, rec() );
SetGeneratorsOfAdditiveMagma( S, [] );
Expand Down
7 changes: 6 additions & 1 deletion lib/magma.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ DeclareCategory( "IsMagmaWithInverses",
IsMagmaWithInversesIfNonzero
and IsMultiplicativeElementWithInverseCollection );

# FIXME: this is wrong for empty magmas
# InstallTrueMethod( IsMagmaWithInverses,
# IsFiniteOrderElementCollection and IsMagma );

InstallTrueMethod( IsMagmaWithInverses,
IsFiniteOrderElementCollection and IsMagma );
IsFiniteOrderElementCollection and IsMagmaWithOne );


#############################################################################
##
Expand Down
54 changes: 54 additions & 0 deletions tst/testbugfix/2018-05-09-submagma.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# There was a bug where we marked a sub additive magma
# with empty generator list as trivial, even though it is empty.
#
# There was also a wrong implication, from "IsFiniteOrderElementCollection and
# IsMagma" to IsMagmaWithInverses. But a collection with the former filters may
# be empty, and then it isn't a IsMagmaWithInverses.
#
gap> amgm:=AdditiveMagma([0]);
<additive magma with 1 generators>
gap> Size(amgm);
1
gap> IsTrivial(amgm);
true
gap> IsEmpty(amgm);
false
gap> IsMagmaWithInverses(amgm);
false

#
gap> asub:=SubadditiveMagma(amgm, []);
<additive magma with 0 generators>
gap> Size(asub);
0
gap> IsTrivial(asub);
false
gap> IsEmpty(asub);
true
gap> IsMagmaWithInverses(asub);
false

#
gap> mgm:=Magma( () );
<commutative semigroup with 1 generator>
gap> Size(mgm);
1
gap> IsTrivial(mgm);
true
gap> IsEmpty(mgm);
false
gap> IsMagmaWithInverses(mgm);
false

#
gap> sub:=Submagma(mgm,[]);
<commutative semigroup with 0 generators>
gap> Size(sub);
0
gap> IsTrivial(sub);
false
gap> IsEmpty(sub);
true
gap> IsMagmaWithInverses(sub);
false