# List all possible elements of a set

I have this two sets:

$A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$

$B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$

Now I want to list all possible elements that are in $B$. How do I do this?

• Are you sure this is related to Mathematica and not to mathematics ? – Sektor Oct 28 '13 at 7:56
• Pretty sure, since I want the program (Wolfram Mathematica, indeed) to list the possibilities for me ;) – afpel Oct 28 '13 at 17:39

If I'm not mistaken you can do this: (I will replace [EmptySet] with ES because I have troubles formatting it here)

a = { ES, {ES}, {{ES}, ES}};

b = {#, {#, #2}} & @@@ Tuples[a, {2}];
% // Column

{ES, {ES, ES}}
{ES, {ES, {ES}}}
{ES, {ES, {{ES}, ES}}}
{{ES}, {{ES}, ES}}
{{ES}, {{ES}, {ES}}}
{{ES}, {{ES}, {{ES}, ES}}}
{{{ES}, ES}, {{{ES}, ES}, ES}}
{{{ES}, ES}, {{{ES}, ES}, {ES}}}
{{{ES}, ES}, {{{ES}, ES}, {{ES}, ES}}}
}


Or even more clear way:

b2 = Table[{x, {x, y}}, {x, a}, {y, a}] // Flatten[#, 1] &;

b2 == b

True

• Great, that's it! Many thanks! – afpel Oct 29 '13 at 13:46