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

Iterator for a free inverse semigroup is broken #536

Closed
wilfwilson opened this issue Sep 22, 2018 · 1 comment
Closed

Iterator for a free inverse semigroup is broken #536

wilfwilson opened this issue Sep 22, 2018 · 1 comment
Assignees
Labels
bug Label for issues or PR which report or fix bugs close-on-minor-release Issues that should remain open until the next minor release, but should then be closed. resolved-pending-release A label for issues that are resolved pending a release.

Comments

@wilfwilson
Copy link
Collaborator

It seems that the iterator for free inverse semigroup only returns products of generators that correspond to reduced products in the free group (minus the identity element). In particular, the iterator produces no words in which a generator is adjacent to its inverse, such as a a^-1. See the first 25 elements produced:

gap> iter := Iterator(FreeInverseSemigroup(["a", "b"]));;
gap> for i in [1 .. 25] do Print(NextIterator(iter), "\n"); od;
a
a^-1
b
b^-1
a*a
a^-1*a^-1
b*a
b^-1*a
b*a^-1
b^-1*a^-1
a*b
a^-1*b
a*b^-1
a^-1*b^-1
b*b
b^-1*b^-1
a*a*a
a^-1*a^-1*a^-1
b*a*a
b^-1*a*a
b*a^-1*a^-1
b^-1*a^-1*a^-1
a*b*a
a^-1*b*a
a*b^-1*a

Ideally, the iterator should iterate over reduced words ordered by ascending length. I'm not sure what the feasibility of this is, but in any case, it seems like the current iterator will not actually iterate over all reduced words. Yes, the semigroup is infinite, but I would expect that for any particular word, given sufficient time, the word will appear in the iterator. The current behaviour doesn't seem a whole lot more useful than the iterator producing "a, a^2, a^3, ..." as the list of elements.

Furthermore, the code doesn't seem to be doing what is intended. The iterator has record components seq, words, and iter_list, but these seem to remain unchanged after iterations:

gap> iter := Iterator(FreeInverseSemigroup(["a", "b"]));;
gap> iter!.seq; iter!.words; iter!.iter_list;
[ 1 ]
[ a ]
[ <iterator> ]
gap> for i in [1 .. 1000] do NextIterator(iter); od;
gap> iter!.seq; iter!.words; iter!.iter_list;
[ 1 ]
[ a ]
[ <iterator> ]

Something is clearly not right here.

Furthermore, there is the issue mentioned before, where the code accesses undocumented record components of an iterator of a free group that are not guaranteed to be there. There is a fix for this: we change the !.word access to a ExtRepOfObj call for the element that we are interested in. But I think it's more important to get the iterator working correctly in a mathematical sense before changing this.

@wilfwilson wilfwilson added the bug Label for issues or PR which report or fix bugs label Sep 22, 2018
@james-d-mitchell james-d-mitchell added 3.* resolved-pending-merge A label for issues that are resolved pending a PR merge. labels Sep 28, 2018
@james-d-mitchell james-d-mitchell self-assigned this Sep 29, 2018
wilfwilson added a commit that referenced this issue Oct 1, 2018
Fix iterators for free inverse semigroups (issue #536) and some new methods for free inverse semigroups
@james-d-mitchell james-d-mitchell added resolved-pending-release A label for issues that are resolved pending a release. close-on-minor-release Issues that should remain open until the next minor release, but should then be closed. and removed resolved-pending-merge A label for issues that are resolved pending a PR merge. labels Oct 1, 2018
@james-d-mitchell
Copy link
Collaborator

Resolved in v3.0.20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Label for issues or PR which report or fix bugs close-on-minor-release Issues that should remain open until the next minor release, but should then be closed. resolved-pending-release A label for issues that are resolved pending a release.
Projects
None yet
Development

No branches or pull requests

2 participants