Disallow duplicate named generators when constructing magmas, semigroups, groups, etc
To me it seems like doing something like FreeGroup("x", "x"); can only possibly lead to potential confusion, I can't see a use case for it and I think it should be disallowed. But I'm open to contrary opinions.
To add:
- [x]
generatorNamesoption for pc groups - [x]
FreeMagma - [x]
FreeMagmaWithOne - [x]
FreeSemigroup - [x]
FreeMonoid - [x]
FreeGroup - [x]
FreeAlgebra - [x]
FreeAlgebraWithOne - [x]
FreeAssociativeAlgebra - [x]
FreeAssociativeAlgebraWithOne - [x]
FreeLieAlgebra - [x]
FreeBandandFreeInverseSemigroup: https://github.com/semigroups/Semigroups/pull/1118
Plus:
- [ ] Add tests for everything
- [ ] Update manual entries for everything
- [ ] Update manual examples
It seems there are manual examples that explicitly use duplicate generators, see for example the part of the manual titled "Comparison of Associative Words" (?Comparison of Associative Words), which gives the example:
gap> f:= FreeGroup( "a", "b", "b" );;
gap> gens:= GeneratorsOfGroup(f);
[ a, b, b ]
gap> gens[2] = gens[3];
false
gap> x:= gens[1]*gens[2];
a*b
gap> y:= gens[2]/gens[2]*gens[1]*gens[2];
a*b
gap> x = y;
true
gap> z:= gens[2]/gens[2]*gens[1]*gens[3];
a*b
gap> x = z;
false
Which demonstrates that x <> z, i.e. a * b <> a * b.
We can also see that AssignGeneratorVariables has the following behaviour with duplicate generator names:
gap> G := FreeGroup("a", "b", "b");
<free group on the generators [ a, b, b ]>
gap> AssignGeneratorVariables(G);
#I Global variable `b' is already defined and will be overwritten
#I Assigned the global variables [ a, b, b ]
I am tempted to forbid it, because I find it hard to imagine someone is using this on purpose, and hasn't just made a typo and is confusing themselves.
I agree with @ChrisJefferson. I think the manual example quoted above should be changed.
My guess is that the idea of this manual example is to demonstrate that words which look equal need not be equal. However, artificially choosing the same name for different generators is not a good example for that lesson, comparing elements from different free objects would make more sense.
I agree with @ThomasBreuer and @ChrisJefferson
I'd be fine with this as well.
I'll try to get it finished soon.
I agree with @ChrisJefferson, @james-d-mitchell and @fingolfin. I doubt, I can find a use-case to use same name for two different generators.