First of all, I work with modular arithmetics and the elements of the arithmetics are lists themselves.
I recognize two kinds of symmetries - shift and mirroring. We could define shift of a list like this:
mod = {3, 2};
shiftBy[set_, shift_] := Mod[shift + #, mod] & /@ set
I consider two sets to be equivalent if one can be obtained from the other by shifting.
The other symmetry is sign swapping at one or more positions, like swap sign on first member of each element. We could define it like this (return all elements with sign flipped on one of the elements members):
mod = {3, 2};
swapSignAt[set_, position_] := Table[
element[[position]] = Mod[-element[[position]], mod][[position]];
element,
{element, set}]
Example
Let's define some sets:
set1 = {{1, 0}, {1, 0}, {2, 1}};
set2 = {{0, 1}, {0, 1}, {1, 0}};
set3 = {{2, 0}, {2, 0}, {1, 1}};
set4 = {{2, 1}, {2, 1}, {1, 0}};
set5 = {{1, 0}, {2, 0}, {2, 1}};
listOfSets = {set1,set2,set3,set4,set5}
In this case set1
, set2
, set3
, set4
are considered to be equivalent because set2 = shiftBy[set1, {2, 1}]
, set3 = swapSignAt[set1, 1]
, set4 = swapSignAt[shiftBy[set1, {0, 1}], 1]
.
I need such a function that would remove me the equivalent elements:
removeEquivalent[listOfLists]
It should return {set1,set5}
(of course the content not the names like set1
) or some other set of 2 non-equivalent sets.
How do I construct such a function? I suppose I should create an equivalence test setsEquivQ
and use DeleteDuplicates[listOfSets, setsEquivQ]
, but the symmetries are so complicated I have trouble constructing such test.
Some notes. The value of
mod
can be list of variable length, in the real codemod
is passed to functions. For example the elements could be triples andmod
could be{8,9,7}
. I also havepossibleShifts[mod]
available - it seems that such list might be handy when testing the shifting equivalence.
Edit: The element order doesn't matter. We could append //Sort
to those symmetry functions to make the sets more standartised.
Edit 2: For the context. What matters for me in the end is Differences @* DeleteDuplicates @ Tuples[set, 2]
- differences of all pairs. This result isn't affected by sorting set
or shifting the elements. And swapping a sign in a component would only swap a sign in result but does not affect the compositions of the result (if 2 of the differences are the same or not same, it will stay that way when sign of one component is flipped on each). However, I am not directly checking the result as some non-equivalent sets can give the same result. Example.
set1
andset2
would be equivalent iffcanonical[set1]==canonical[set2]
? $\endgroup$