Sub topic 13
Counting Subsets and the Power Set
Prerequisites and the working model
Assume you can read basic set notation and perform powers and multiplication. A set is a collection of distinct elements. For example, let \(A = \{1, 2, 3\}\).
A subset is a set whose every element belongs to another set. We write \(B \subseteq A\). For example, \(\{1, 3\} \subseteq A\). The empty set, written \(\varnothing\), is a subset of every set. The original set is also a subset of itself.
The power set of \(A\), written \(\mathcal{P}(A)\), is the set containing every subset of \(A\).
Why the number of subsets is \(2^n\)
Suppose a set has \(n\) distinct elements. When constructing a subset, each element has exactly two choices:
- include the element;
- leave the element out.
These choices are independent. Therefore, the total number of subsets is
\[ 2 \times 2 \times \cdots \times 2 = 2^n \]
where the factor 2 appears once for each element.
For \(A = \{1, 2, 3\}\), there are \(2^3 = 8\) subsets:
\[ \varnothing,\{1\},\{2\},\{3\},\{1,2\},\{1,3\},\{2,3\},\{1,2,3\} \]
The number of subsets depends only on the number of distinct elements, not on the elements themselves.
| Number of elements \(n\) | Total subsets \(2^n\) | Proper subsets \(2^n-1\) |
|---|---|---|
| 3 | 8 | 7 |
| 5 | 32 | 31 |
| 10 | 1,024 | 1,023 |
A proper subset is a subset that is not equal to the original set. Since the original set is one of its own subsets, subtract 1 to count proper subsets.
def subset_count(n):
return 2 ** n
n = 5
print("All subsets:", subset_count(n))
print("Proper subsets:", subset_count(n) - 1)Counting subsets of a fixed size
The formula \(2^n\) counts subsets of every possible size. Sometimes a question asks for subsets containing exactly \(r\) elements. Then use the combination formula:
\[ \binom{n}{r}=\frac{n!}{r!(n-r)!} \]
For example, the number of three-element subsets of a seven-element set is
\[ \binom{7}{3} = \frac{7!}{3!4!} = 35 \]
The word “choose” usually signals this calculation. If a question asks for subsets with at least one element, use \(2^n-1\). If it asks for subsets with at most two elements, add the relevant combinations:
\[ \binom{n}{0}+\binom{n}{1}+\binom{n}{2} \]
Visual model
CAT traps and checks
Do not confuse the number of elements with the number of subsets. A set with 8 elements has \(2^8 = 256\) subsets, not 16.
Also distinguish between an element and a set containing that element. If \(A=\{1,2\}\), then \(1\in A\), but \(\{1\}\subseteq A\). The statement \(1\subseteq A\) is not meaningful in ordinary set notation because 1 is an element, not a set.
For a quick check, the number of \(r\)-element subsets is \(\binom{n}{r}\), and adding these counts for \(r=0\) through \(n\) must give \(2^n\).
Exercise
A set has 6 distinct elements. How many subsets contain exactly 2 elements, and how many non-empty subsets does it have?
Show answer
Exactly 2 elements: \(\binom{6}{2}=15\). Non-empty subsets: \(2^6-1=63\).