Skip to main content

Set Theory Explained: Union, Intersection, Complement, and Power Sets

Learn set theory operations with examples: union, intersection, difference, symmetric difference, complement, subset checks, and power sets.

What Is a Set?

A set is an unordered collection of distinct objects called elements. Curly braces denote a set: 3 is a set containing the integers 1, 2, and 3. Order does not matter — 3 and 2 are the same set. Repetition is ignored — 2 is the same as 2.

The empty set, written ∅ or , contains no elements. The cardinality of a set |A| is its number of distinct elements.

Union (A ∪ B)

The union of two sets contains every element that appears in either set:

A ∪ B = {x | x ∈ A or x ∈ B}

Duplicates are removed because sets contain only distinct elements.

Example: A = 3, B = 5

A ∪ B = {1, 2, 3, 4, 5}

Element 3 appears in both A and B but only once in the union.

Cardinality rule: |A ∪ B| = |A| + |B| − |A ∩ B| (inclusion-exclusion principle)

Worked Example

Set A: 3 — three elements Set B: 5 — three elements

Union:

A ∪ B = {1, 2, 3, 4, 5}

Result: The union has 5 elements. Element 3 was shared and counted once.

By inclusion-exclusion: |A| + |B| − |A ∩ B| = 3 + 3 − 1 = 5. ✓

Intersection (A ∩ B)

The intersection contains only elements that appear in both sets:

A ∩ B = {x | x ∈ A and x ∈ B}

Example: A = 3, B = 5

A ∩ B = {3}

If two sets share no elements, their intersection is ∅. Such sets are called disjoint.

Set Difference (A − B)

The difference A − B contains elements of A that are not in B:

A − B = {x | x ∈ A and x ∉ B}

Example: A = 3, B = 5

A − B = {1, 2}    (elements in A but not B)
B − A = {4, 5}    (elements in B but not A)

Note: A − B ≠ B − A in general — set difference is not commutative.

Symmetric Difference (A △ B)

The symmetric difference contains elements in either A or B but not both:

A △ B = (A − B) ∪ (B − A)

Example: A = 3, B = 5

A △ B = {1, 2} ∪ {4, 5} = {1, 2, 4, 5}

Unlike set difference, symmetric difference is commutative: A △ B = B △ A.

Complement (A̅ = U − A)

The complement of A (relative to a universal set U) contains elements in U that are not in A:

A̅ = U − A = {x | x ∈ U and x ∉ A}

The universal set U must be specified — it defines the “universe of discourse” for a given problem.

Example: U = 5, A = 2

A̅ = {3, 4, 5}

Subset and Superset

A is a subset of B (written A ⊆ B) if every element of A is also in B. A is a proper subset (A ⊂ B) if A ⊆ B and A ≠ B.

Every set is a subset of itself. The empty set is a subset of every set.

Power Set

The power set 𝒫(A) is the set of all possible subsets of A, including ∅ and A itself.

Example: A = {a, b}

𝒫(A) = {∅, {a}, {b}, {a, b}}

If |A| = n, then |𝒫(A)| = 2ⁿ. For n = 4, that is 16 subsets; for n = 10, it is 1,024. The exponential growth makes explicit enumeration impractical beyond about 20 elements.

Applications of Set Theory

Database queries: SQL’s UNION, INTERSECT, and EXCEPT operations are directly the set union, intersection, and difference.

Logic and circuits: Boolean algebra is isomorphic to set theory — AND corresponds to intersection, OR to union, NOT to complement.

Probability: Events are sets, and the probability rules for unions and intersections follow directly from set theory.

Formal language theory: Grammars, automata, and compiler design use set operations to describe languages and token classes.