Search

Search papers and lessons

Power Set

Level 1 · 10 min read

The power set of a set is the collection of all its subsets, and a set with n elements always has 2 to the power n subsets.

On this page

  • Colour = topic mix
  • Discrete math
  • ReadReady to readNot yet

TL;DR

The power set of a set SS is the collection of every subset of SS, including the empty set and SS itself. It answers the question "in how many ways can I pick some of these things?" and it is the basic object behind counting combinations. If SS has nn elements, its power set has 2n2^n elements, a fact that grows very fast as nn grows.

Builds on: Set Operations · Leads to: topological spaces, which are built from collections of subsets

Where it's used

Probability. A die has six faces, so its sample space is {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\}. An event such as "the roll is even" is a subset of that space. The power set of the sample space is the collection of all possible events, and it has 26=642^6 = 64 members. Probability theory assigns a number to each of those 64 events.

Feature selection in statistics. Suppose a regression model could use any of 20 candidate predictors. Choosing a model means choosing a subset of the 20. There are 220=1,048,5762^{20} = 1{,}048{,}576 such subsets, so the power set is the full search space of possible models. Methods like best-subset selection try to score every member of it, and this is why they become slow once the number of predictors is large.

Computer memory. A set of 8 switches, each on or off, can be stored as one byte. Each byte is one subset of the 8 switches: a bit set to 1 means that switch is in the subset. The 256 possible byte values are exactly the 256 subsets of the 8 switches, which is the power set of an 8-element set. Programmers call this a bitmask.

How it works

Take a tiny set S={1,2,3}S = \{1, 2, 3\}. We will build its power set one element at a time, starting from the empty set.

  1. Start with one subset. The list holds only the empty set, ∅\emptyset, which has no elements. Check: the list has 1 subset, and 20=12^0 = 1.
  2. Add the element 1. For every subset already on the list, keep it, and also make a copy with 1 put in. The empty set gives ∅\emptyset and {1}\{1\}. Check: 2 subsets, and 21=22^1 = 2.
  3. Add the element 2. Again, keep every subset on the list, and make a copy of each with 2 added. The list ∅,{1}\emptyset, \{1\} gives {2}\{2\} and {1,2}\{1, 2\}. Now the list is ∅,{1},{2},{1,2}\emptyset, \{1\}, \{2\}, \{1, 2\}. Check: 4 subsets, and 22=42^2 = 4.
  4. Add the element 3. Copy each of the 4 subsets with 3 added: {3},{1,3},{2,3},{1,2,3}\{3\}, \{1, 3\}, \{2, 3\}, \{1, 2, 3\}. The list now has 8 subsets. Check: 23=82^3 = 8.

The rule at every step is the same. Each element is either in a subset or out of it, so each subset already on the list gives two new subsets. Adding one element doubles the count. The final list is

P(S)={∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}.\mathcal{P}(S) = \{\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\}\}.

A second way to see the same 8 subsets uses binary. Write each subset as a 3-digit string, with a 1 in the position of each element that is present:

BinarySubset
000∅\emptyset
001{3}\{3\}
010{2}\{2\}
011{2,3}\{2, 3\}
100{1}\{1\}
101{1,3}\{1, 3\}
110{1,2}\{1, 2\}
111{1,2,3}\{1, 2, 3\}

Counting from 0 to 7 in binary visits every subset exactly once, which is another reason the count is 23=82^3 = 8.

The math

Definition

Definition: Power set

For a set SS, the power set P(S)\mathcal{P}(S) is the set of all subsets of SS: P(S)={A∣A⊆S}.\mathcal{P}(S) = \{A \mid A \subseteq S\}. Here A⊆SA \subseteq S means every element of AA is also an element of SS. Both ∅\emptyset and SS are members of P(S)\mathcal{P}(S).

Each member of P(S)\mathcal{P}(S) is itself a set. So P(S)\mathcal{P}(S) is a set of sets, and it can be written with curly braces around the subsets.

Step 2 in symbols

Let TT be a set and let xx be an element not in TT. Every subset of T∪{x}T \cup \{x\} falls into exactly one of two groups:

  • It does not contain xx. Then it is a subset of TT. There are ∣P(T)∣|\mathcal{P}(T)| of these.
  • It contains xx. Then removing xx leaves a subset of TT, and adding xx back to any subset of TT gives one of these. So there are again ∣P(T)∣|\mathcal{P}(T)| of these.

The two groups do not overlap, so

∣P(T∪{x})∣=∣P(T)∣+∣P(T)∣=2 ∣P(T)∣.|\mathcal{P}(T \cup \{x\})| = |\mathcal{P}(T)| + |\mathcal{P}(T)| = 2\,|\mathcal{P}(T)|.

This is the doubling from step 2 of the walkthrough. The symbol ∣X∣|X| means the number of elements of XX.

The general count

Let ∣S∣=n|S| = n. The claim is ∣P(S)∣=2n|\mathcal{P}(S)| = 2^n. We prove it by induction on nn.

  • Base case, n=0n = 0. Then S=∅S = \emptyset, and its only subset is ∅\emptyset. So P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}, which has 1=201 = 2^0 element.
  • Inductive step. Assume ∣P(T)∣=2k|\mathcal{P}(T)| = 2^k for every set TT with kk elements. Take SS with k+1k + 1 elements, pick one element xx of SS, and let T=S∖{x}T = S \setminus \{x\}. Then TT has kk elements and S=T∪{x}S = T \cup \{x\}. By the doubling argument, ∣P(S)∣=2⋅2k=2k+1|\mathcal{P}(S)| = 2 \cdot 2^k = 2^{k+1}.

Counting by size

Subsets of SS with exactly kk elements are counted by the binomial coefficient

(nk)=n!k! (n−k)!.\binom{n}{k} = \frac{n!}{k!\,(n-k)!}.

Every subset has some size from 00 to nn, so

∑k=0n(nk)=2n,\sum_{k=0}^{n} \binom{n}{k} = 2^n,

which agrees with the count 2n2^n. For S={1,2,3}S = \{1, 2, 3\} the sizes are 1,3,3,11, 3, 3, 1, and 1+3+3+1=81 + 3 + 3 + 1 = 8.

Worked examples

Example
Example 1: one element

Let S={a}S = \{a\}.

  1. The subsets of SS are the ones that contain nothing and the ones that contain aa.
  2. The empty set ∅\emptyset is a subset, because it has no elements that fail to be in SS.
  3. The set {a}\{a\} is a subset, because it is SS itself.
  4. There are no other subsets.
  5. So P(S)={∅,{a}}\mathcal{P}(S) = \{\emptyset, \{a\}\}, which has 2 elements. This matches 21=22^1 = 2.
Example
Example 2: three elements, the standard case

Let S={x,y,z}S = \{x, y, z\}.

  1. Count by size. Size 0: one subset, ∅\emptyset. That is (30)=1\binom{3}{0} = 1.
  2. Size 1: {x},{y},{z}\{x\}, \{y\}, \{z\}. That is (31)=3\binom{3}{1} = 3.
  3. Size 2: {x,y},{x,z},{y,z}\{x,y\}, \{x,z\}, \{y,z\}. That is (32)=3\binom{3}{2} = 3.
  4. Size 3: SS itself. That is (33)=1\binom{3}{3} = 1.
  5. Add the counts: 1+3+3+1=81 + 3 + 3 + 1 = 8.
  6. The formula 23=82^3 = 8 gives the same answer, so the count is right.
  7. The result is a useful check: whenever you list the subsets by size, the sizes must add up to 2n2^n.
Example
Example 3: a realistic search space

A team is choosing which of 20 features to include in a model. Each feature is either included or left out, so a candidate model is a subset of the 20 features.

  1. The number of candidate models is the size of the power set, 2202^{20}.
  2. Compute 210=10242^{10} = 1024.
  3. Then 220=(210)2=10242=1,048,5762^{20} = (2^{10})^2 = 1024^2 = 1{,}048{,}576.
  4. Suppose fitting and scoring one model takes 1 millisecond. Then trying all of them takes 1,048,5761{,}048{,}576 milliseconds.
  5. Convert to seconds by dividing by 1000: 1048.5761048.576 seconds.
  6. Convert to minutes by dividing by 60: about 17.517.5 minutes.
  7. Adding a 21st feature doubles the work, so the time for 21 features is about 35 minutes. This is why exhaustive search becomes impractical as the number of features grows.

Try it: how many subsets of a 10-element set have exactly 2 elements? Use (102)=10⋅92\binom{10}{2} = \dfrac{10 \cdot 9}{2}.

Answer: 10⋅92=45\dfrac{10 \cdot 9}{2} = 45. Of the 210=10242^{10} = 1024 subsets, only 45 have size 2.

Common mistakes and tradeoffs

Mistake 1: confusing ∅\emptyset with {∅}\{\emptyset\}. It is tempting to think that the power set of the empty set is empty. In fact P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}. The empty set has zero elements, but {∅}\{\emptyset\} is a set that contains one element, the empty set. So the power set of ∅\emptyset has one element, matching 20=12^0 = 1.

Mistake 2: forgetting the ends. People often list only the "real" subsets and leave out ∅\emptyset or SS itself. Both are subsets, and both count. For a set of three elements, forgetting them gives 6 instead of 8.

Mistake 3: treating order as meaningful. The sets {1,2}\{1, 2\} and {2,1}\{2, 1\} are the same set, so the power set contains it only once. If order matters, you are counting sequences or arrangements, which is a different problem.

When to use it. Use the power set when every combination of items is a legitimate choice, and you need to count, enumerate or reason about all of them. It is the right model for events in probability, for choices of options, and for bitmask states.

When not to use it. The count 2n2^n doubles with every element added. Once a set has a few dozen elements, listing every subset is out of reach for an ordinary computer. In those cases people restrict the search to subsets of a fixed size, which gives (nk)\binom{n}{k} choices, or use greedy and heuristic methods that look at only a small part of the power set.

History

Georg Cantor was working on infinite sets in the early 1890s. In 1891 he gave his diagonal argument, which shows that no set can be matched one-to-one with its own power set. In particular the power set of an infinite set is always strictly larger than the set itself. This result, now called Cantor's theorem, caught on because it showed that infinities come in different sizes.

When Ernst Zermelo set out axioms for set theory in 1908, he included a power set axiom: for every set there exists a set that contains all of its subsets. Later axiomatizations, now the standard Zermelo–Fraenkel system, kept this axiom. The idea of collecting all subsets is therefore a basic building block of modern mathematics, not just a counting tool.

Recap

  • A subset of SS is any set whose elements all belong to SS, including ∅\emptyset and SS.
  • The power set P(S)\mathcal{P}(S) collects every subset of SS.
  • Each element is either in or out of a subset, so adding an element doubles the count: ∣P(S)∣=2n|\mathcal{P}(S)| = 2^n for nn elements.
  • The subsets of size kk number (nk)\binom{n}{k}, and these sum to 2n2^n.
  • Next, read Topological Space, which uses a power set as its starting point, and Mathematical Induction if the counting proof above felt unfamiliar.

Check yourself

QuestionHow many elements does the power set of {p,q,r,s}\{p, q, r, s\} have?Show answer

It has 24=162^4 = 16 elements. Each of the four elements is either in or out of a subset, so the number of subsets is 2×2×2×2=162 \times 2 \times 2 \times 2 = 16.

QuestionCompute ∣P(S)∣|\mathcal{P}(S)| for S={1,2,3,4,5,6}S = \{1, 2, 3, 4, 5, 6\} and explain the answer.Show answer

The answer is 26=642^6 = 64. Start from ∅\emptyset, which has 0 elements. Each of the 6 elements doubles the list of subsets, so the count is 26=642^6 = 64. This is the number of events for a fair die, as in the probability example.

QuestionWhy is P(∅)\mathcal{P}(\emptyset) not the empty set?Show answer

Because the empty set has no elements, but P(∅)\mathcal{P}(\emptyset) must contain at least one subset: ∅\emptyset is a subset of ∅\emptyset. So P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}, a set with one element. Its size 1=201 = 2^0 matches the formula.

QuestionA set has 5 elements. How many of its subsets have exactly 3 elements?Show answer

Use the binomial coefficient (53)=5!3! 2!=1206⋅2=10\binom{5}{3} = \dfrac{5!}{3!\,2!} = \dfrac{120}{6 \cdot 2} = 10. There are 10 subsets of size 3.

QuestionA colleague says a feature-selection method that scores all subsets of 30 features will finish quickly because each score is cheap. Is this a sound argument?Show answer

No. The power set of 30 features has 2302^{30}, about 1.07 billion, subsets. Even if each score takes a microsecond, that is roughly 18 minutes of work, and the cost doubles with each added feature. The number of subsets, not the cost of one score, controls the running time.

Sources