Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
up vote 9 down vote accepted

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
share|improve this answer
Great, that's it! Many thanks! – afpel Oct 29 '13 at 13:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.