Powerset with constraints

182 Views Asked by At

I have two sets $NUMBERS$ and $LETTERS$ with:

$ NUMBERS = \{1, 2, 3, 4, 5\} \\ LETTERS = \{ A, B, C, D, E\}$

No I want the power-set of my sets, i.e. the set of subsets of elements from both $NUMBERS$ and $LETTERS$ that contain at least one element of $NUMBERS$ and one element of $LETTERS$.
But with two constraints:

  1. If the new set contains either $1$ or $2$, it also has to contain $2$ or $1$.
    Short: $1$ and $2$ may occur together only.

Not allowed:

  • $1CB$ (1, but no 2)
  • $23B$ (2, but no 1)

Allowed:

  • $12CB$ (1 together with 2)
  • $21A$ (2 together with 1)
  • $3C$ (no 1 or 2 at all)

    1. A and B are not allowed to occur together.

Not allowed:

  • $3AB$ (A and B together)
  • $23BCA$ (B and A together)

Allowed:

  • $12CB$ (Only B, but no A)
  • $21A$ (Only A, but no B)
  • $345D$ (Neither A, nor B)

I learned here, that the formula for the power sets in my case is: $P(NUMBERS ∪LETTERS )\setminus(P(NUMBERS )∪P(LETTERS ))$, but I'm not sure, how to define my constraints.

How can I change my formula to meet my constraints?

1

There are 1 best solutions below

2
On

CORRECTION: my original answer double counted some cases. I believe this version fixes that error.

In the set NUMBERS, treat the elements {1,2} as a single element X. Thus the set NUMBERS is replaced with NUMBERS* = {X, 3, 4, 5}. That ensures that your first constraint is always satisfied. To handle the second, first look at $LETTERS_1$= {A, C, D, E}. Forming sets between these, and using at least one element from each, just means picking a non empty subset of each. Thus there are $(2^4 -1)^2$ ways to do it. The same observations pertain to $LETTERS_2$ = {B, C, D, E}. Adding these double counts the cases where neither A nor B occurs, hence we must subtract eligible sets formed between NUMBERS* and {3,4,5}. There are $(2^4 -1)^2 (2^3 - 1)$ of these. Hence the total is $2 (2^4 -1)^2 - (2^4 -1)(2^3-1) $ which works out to 550 - 105 = 345.