Symmetry
The single example provided to illustrate the notion of symmetry doesn't rule out situations where the shape/structure of the two lists may differ.
Depending on whether or not we require the two lists to have the same shape in addition to they being same up to relabeling of atomic elements, we can have two different formalizations of symmetry. The first case can be captured using the ArrayComponents
of the two lists; if list1
and list2
have the same ArrayComponents
they have the same shape and they are same up to relabeling of atomic elements. Symmetry where shape doesn't matter can be checked using Flatten
ned ArrayComponents
of the two lists (or, the same thing, ArrayComponents
of the Flatten
ned lists). For example:
lst0 = {{"a"}, {"b"}, {"c"}, {"a", "b"}, {"a", "c"}, {"b", "c"}};
lst1 = {{"b"}, {"a"}, {"c"}, {"b", "a"}, {"b", "c"}, {"a", "c"}};
lst2 = { {"b", "a"}, {"b", "c"}, {"a", "c"} ,{"b"}, {"a"}, {"c"}};
lst3 = {{"a","b","c"}, {"a", "b"}, {"a", "c"}, {"b", "c"}};
symQ1 = Equal[ArrayComponents[#], ArrayComponents[#2]] &;
symQ1[lst0, #] & /@ {lst1, lst2, lst3}
{True, False, False}
symQ2 = Equal[Flatten@ArrayComponents[#], Flatten @ ArrayComponents[#2]] &;
symQ2[lst0, #] & /@ {lst1, lst2, lst3}
{True, False, True}
Generating "shuffles"
By "permutations" of lst0
you seem to mean a combination of Permutations[lst0]
and relabeling of atomic elements (Permutations[{"a","b","c"}]
). Let's call such things shuffles
.
abc = {"a", "b", "c"};
rule = Thread[abc -> #] & /@ Permutations[abc];
labelings = lst0 /. rule ;
MemberQ[labelings , #] & /@ {lst0, lst1, lst2, lst3}
{True, True, False, False}
labelings // Column // TeXForm
$\begin{array}{l}
\{\{a\},\{b\},\{c\},\{a,b\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{c\},\{b\},\{a,c\},\{a,b\},\{c,b\}\} \\
\{\{b\},\{a\},\{c\},\{b,a\},\{b,c\},\{a,c\}\} \\
\{\{b\},\{c\},\{a\},\{b,c\},\{b,a\},\{c,a\}\} \\
\{\{c\},\{a\},\{b\},\{c,a\},\{c,b\},\{a,b\}\} \\
\{\{c\},\{b\},\{a\},\{c,b\},\{c,a\},\{b,a\}\} \\
\end{array}$
perms = Permutations[lst0];
shuffles = Join @@ (perms /. rule);
MemberQ[shuffles , #] & /@ {lst0, lst1, lst2, lst3}
{True, True, True, False}
Length @ shuffles
4320
shuffles[[;; 10]] // Column // TeXForm
$\begin{array}{l}
\{\{a\},\{b\},\{c\},\{a,b\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,b\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{a,b\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{b,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,b\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{b,c\},\{c\}\} \\
\end{array}$
Symmetry-free subsets
Using symQ1
and symQ2
we get two different symmetry-free subsets of shuffles
:
asymm1 = DeleteDuplicatesBy[ArrayComponents][shuffles];
asymm1 // Length
720
MemberQ[asymm1, #] & /@ {lst0, lst1, lst2, lst3}
{True, False, False, False}
asymm1[[;; 10]] // Column // TeXForm
$\begin{array}{l}
\{\{a\},\{b\},\{c\},\{a,b\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,b\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{a,b\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{b,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,b\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{b,c\},\{c\}\} \\
\end{array}$
asymm2 = DeleteDuplicatesBy[Flatten[ArrayComponents@#] &][shuffles] ;
asymm2 // Length
213
MemberQ[asymm2, #] & /@ {lst0, lst1, lst2, lst3}
{True, False, False, False}
asymm2[[;; 10]] // Column // TeXForm
$\begin{array}{l}
\{\{a\},\{b\},\{c\},\{a,b\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,b\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{a,b\},\{b,c\}\} \\
\{\{a\},\{b\},\{c\},\{a,c\},\{b,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,b\},\{a,c\}\} \\
\{\{a\},\{b\},\{c\},\{b,c\},\{a,c\},\{a,b\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{a,c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{c\},\{b,c\},\{a,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{c\},\{b,c\}\} \\
\{\{a\},\{b\},\{a,b\},\{a,c\},\{b,c\},\{c\}\} \\
\end{array}$