Skip to content

Commit

Permalink
Merge pull request #462 from mtorpey/fix-issue-461
Browse files Browse the repository at this point in the history
Fix issue #461 (NrCongruenceClasses)
  • Loading branch information
wilfwilson authored Feb 22, 2018
2 parents 48cc1ee + 3a4a197 commit f5c867e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gap/congruences/cong.gi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
InstallMethod(NrEquivalenceClasses, "for a semigroup congruence",
[IsSemigroupCongruence],
function(cong)
return Length(EquivalenceClasses(cong));
local classes;
classes := EquivalenceClasses(cong);
# Note: EquivalenceClasses may exclude all singletons due to a bug in GAP.
# This is a workaround which adds any missing singletons.
return Length(classes) + Size(Range(cong)) - Sum(classes, Size);
end);

InstallMethod(\in,
Expand Down
14 changes: 14 additions & 0 deletions tst/testinstall.tst
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,19 @@ false
gap> Size(M0);
0

# Issue 461: NrCongruenceClasses gives incorrect answer
gap> tab := [[1, 2, 3, 3], [2, 3, 1, 1], [3, 1, 2, 2], [3, 1, 2, 2]];;
gap> S := SemigroupByMultiplicationTable(tab);;
gap> cong := SemigroupCongruence(S, [[S.3, S.4]]);;
gap> S.1 in EquivalenceClassOfElement(cong, S.3);
false
gap> NrCongruenceClasses(cong);
3
gap> S.1 in EquivalenceClassOfElement(cong, S.3);
false
gap> IsUniversalSemigroupCongruence(cong);
false

#T# SEMIGROUPS_UnbindVariables
gap> Unbind(B);
gap> Unbind(D);
Expand Down Expand Up @@ -1787,6 +1800,7 @@ gap> Unbind(rel);
gap> Unbind(s);
gap> Unbind(sgns);
gap> Unbind(t);
gap> Unbind(tab);
gap> Unbind(tuples);
gap> Unbind(u);
gap> Unbind(x);
Expand Down

0 comments on commit f5c867e

Please sign in to comment.