4
$\begingroup$

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?

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

1 Answer 1

9
$\begingroup$

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
$\endgroup$
1
  • $\begingroup$ Great, that's it! Many thanks! $\endgroup$
    – afpel
    Commented Oct 29, 2013 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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