DISCRETE MATH • SETS, RELATIONS, AND FUNCTIONS

Set notation and operations (union, intersection, complement)

The foundational language of modern mathematics, unifying logic, algebra, and computation under one framework.

Historical Context & Motivation

The notion of grouping objects into collections is as old as human thought itself, but the rigorous mathematical treatment of such collections — set theory — did not emerge until the late nineteenth century. Before Georg Cantor's pioneering work, mathematicians operated with informal notions of 'families' and 'classes' of numbers, functions, and geometric objects, but lacked a unified formal language to describe them. The impetus for formalizing set theory arose from deep questions in analysis, particularly the study of convergence and the nature of the real number line. What emerged was not merely a convenient notation, but an entirely new foundation upon which virtually all of modern mathematics would come to rest.

1874
Cantor's Foundational Paper
Georg Cantor publishes his landmark paper establishing that the set of real numbers is uncountable, thereby demonstrating that infinite sets can have different cardinalities and launching set theory as a distinct mathematical discipline.
1888
Dedekind's Contributions
Richard Dedekind publishes 'Was sind und was sollen die Zahlen?' introducing the concept of set-theoretic mappings (functions) between sets and formalizing the natural numbers via what are now called Dedekind-infinite sets.
1895–1897
Cantor's Beiträge
Cantor publishes his two-part 'Beiträge zur Begründung der transfiniten Mengenlehre,' systematically developing cardinal and ordinal arithmetic and solidifying the notation and operations of set theory.
1901
Russell's Paradox
Bertrand Russell discovers the paradox bearing his name — the set of all sets that do not contain themselves — exposing a critical flaw in naive set theory and motivating the search for axiomatic foundations.
1908
Zermelo's Axiomatization
Ernst Zermelo publishes his axiomatization of set theory, later extended by Abraham Fraenkel into ZFC (Zermelo–Fraenkel with Choice), which remains the standard axiomatic framework for modern mathematics.

The fundamental question that set theory answers is deceptively simple: How can we precisely describe collections of objects and the relationships among those collections? From this question springs a rich algebraic structure of operations — union, intersection, complement, and others — that mirrors the logical connectives of propositional logic and provides the vocabulary for fields ranging from probability theory and database design to formal language theory and topology. Understanding set notation and operations is therefore not an isolated exercise but a gateway to the formal reasoning that pervades higher mathematics and computer science.

Core Principles & Definitions

A set is an unordered collection of distinct objects, called elements or members. We write x ∈ A to assert that x is an element of set A, and x ∉ A to deny membership. Sets are typically denoted by uppercase Latin letters (A, B, C, …) while elements are denoted by lowercase letters (a, b, c, …). Two sets are equal if and only if they contain exactly the same elements — this is the Axiom of Extensionality. Because sets are unordered and contain no duplicates, {1, 2, 3} = {3, 1, 2} = {1, 1, 2, 3}.

1

Roster (Enumeration) Notation

List elements explicitly within braces: A = {2, 4, 6, 8}. Best suited for finite sets of manageable size. Ellipses (…) may indicate a pattern: ℕ = {0, 1, 2, …}.
2

Set-Builder Notation

Specify elements by a predicate: B = {x ∈ ℤ | x² < 20}. Read as 'the set of all integers x such that x² is less than 20.' This notation is essential for describing infinite or implicitly defined sets.
3

Universal Set (U)

The universal set is the ambient 'universe of discourse' containing all elements under consideration. All sets in a given discussion are subsets of U. The complement operation is defined relative to U.
4

Subset & Proper Subset

A ⊆ B means every element of A is also in B. A ⊂ B (proper subset) adds the requirement A ≠ B. Every set is a subset of itself, and the empty set ∅ is a subset of every set.
5

The Empty Set (∅)

The unique set with no elements, denoted ∅ or {}. It is a subset of every set. Its cardinality is |∅| = 0. The power set of ∅ is {∅}, which has exactly one element.
KEY TAKEAWAY
Think of a set as a labeled container — like a folder on your computer's file system. The folder's name is the set's label (A, B, …), and the files inside are the elements. Two folders are 'equal' when they contain exactly the same files, regardless of the order in which they were added. Set operations are the equivalent of merging folders (union), finding common files (intersection), or listing everything not in a folder (complement).

Venn Diagram Visualization

The Venn diagram, introduced by John Venn in 1880, remains the most intuitive way to visualize set relationships. In a standard two-set Venn diagram, each set is represented by a circle within a rectangle (the universal set U). The regions formed by overlapping circles correspond to the fundamental set operations: the overlap is the intersection, the total area covered by both circles is the union, and everything outside a given circle (but inside U) is that set's complement.

A two-set Venn diagram showing the four fundamental regions: elements only in A (the set difference A \ B, shaded violet), elements only in B (B \ A, shaded cyan), elements in both (A ∩ B, shaded pink), and elements in neither set ((A ∪ B)ᶜ, the unmarked region of U).

Observe that the rectangle partitions into exactly four mutually exclusive, collectively exhaustive regions. Every element of U belongs to precisely one of these four regions: A only, B only, both, or neither. This partition is the visual embodiment of the fact that, for any element x ∈ U, the truth values of the propositions x ∈ A and x ∈ B determine exactly one of the four combinations (T,T), (T,F), (F,T), (F,F). This correspondence between set operations and logical connectives — union with disjunction (∨), intersection with conjunction (∧), complement with negation (¬) — is a deep structural parallel that we will formalize in Section 4.

Mathematical Framework

Set operations can be defined precisely using logical predicates. Given a universal set U and subsets A, B ⊆ U, we define the three fundamental operations — union, intersection, and complement — in terms of element membership.

UNION
A ∪ B = { x ∈ U | x ∈ A ∨ x ∈ B }
The union of A and B is the set of all elements that belong to A, to B, or to both. Corresponds to logical disjunction (OR). Note that union is inclusive — elements in both sets appear once.
INTERSECTION
A ∩ B = { x ∈ U | x ∈ A ∧ x ∈ B }
The intersection of A and B is the set of all elements that belong to both A and B simultaneously. Corresponds to logical conjunction (AND). If A ∩ B = ∅, the sets are called disjoint.
COMPLEMENT
Aᶜ = A' = U \ A = { x ∈ U | x ∉ A }
The complement of A (relative to U) is the set of all elements in the universal set that are not in A. Corresponds to logical negation (NOT). Notation varies: Aᶜ, A', and Ā are all common.
SET DIFFERENCE
A \ B = A − B = { x ∈ U | x ∈ A ∧ x ∉ B } = A ∩ Bᶜ
The set difference (or relative complement) of B in A consists of elements in A that are not in B. Note that A \ B ≠ B \ A in general — set difference is not commutative.
🔗 Set–Logic Correspondence
The algebraic structure of set operations under union, intersection, and complement forms a Boolean algebra — the same structure underlying propositional logic and digital circuit design. Specifically, (𝒫(U), ∪, ∩, ᶜ, ∅, U) satisfies all Boolean algebra axioms, where 𝒫(U) denotes the power set of U.

Fundamental Set Identities

Just as algebraic identities govern arithmetic, a collection of identities governs set operations. These identities can be proved using element-wise arguments (showing mutual subset containment), Venn diagrams, or algebraic manipulation via Boolean algebra axioms. The following table catalogs the most important identities, many of which mirror laws from propositional logic.

De Morgan's Laws visualized: the left diagram shows that the complement of the union (amber shading outside both circles) equals the intersection of the complements. The right diagram shows that the complement of the intersection (red shading outside the overlap) equals the union of the complements. The table below summarizes all fundamental set algebra laws.
Key set algebra identities
LawUnion FormIntersection Form
IdentityA ∪ ∅ = AA ∩ U = A
DominationA ∪ U = UA ∩ ∅ = ∅
IdempotentA ∪ A = AA ∩ A = A
ComplementA ∪ Aᶜ = UA ∩ Aᶜ = ∅
Double Complement(Aᶜ)ᶜ = A
AbsorptionA ∪ (A ∩ B) = AA ∩ (A ∪ B) = A
KEY TAKEAWAY
De Morgan's Laws are the set-theoretic analogue of distributing a negation over a logical expression. In programming, the logical equivalence !(p || q) == (!p && !q) is De Morgan's Law in disguise. Whenever you complement a union, swap it for the intersection of complements — and vice versa.

Worked Example

Let us work through a multi-part problem that exercises all three fundamental operations and applies key identities.

📝 Problem Statement
Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, A = {1, 2, 3, 4, 5}, and B = {3, 4, 5, 6, 7}. Find: (a) A ∪ B, (b) A ∩ B, (c) Aᶜ, (d) A \ B, (e) (A ∪ B)ᶜ, and verify De Morgan's Law (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.
Computing Set Operations Step by Step
1
Step 1 — Compute A ∪ BCollect all elements that are in A or in B (or both). A = {1, 2, 3, 4, 5} and B = {3, 4, 5, 6, 7}. The elements 3, 4, 5 are common but appear only once in the union.
A ∪ B = {1, 2, 3, 4, 5, 6, 7}
2
Step 2 — Compute A ∩ BCollect only those elements common to both A and B. We check each element of A for membership in B: 1 ∉ B, 2 ∉ B, 3 ∈ B ✓, 4 ∈ B ✓, 5 ∈ B ✓.
A ∩ B = {3, 4, 5}
3
Step 3 — Compute Aᶜ and BᶜThe complement of A consists of all elements of U not in A. Aᶜ = U \ A = {6, 7, 8, 9, 10}. Similarly, Bᶜ = U \ B = {1, 2, 8, 9, 10}.
Aᶜ = {6, 7, 8, 9, 10}, Bᶜ = {1, 2, 8, 9, 10}
4
Step 4 — Compute A \ BThe set difference A \ B consists of elements in A that are not in B. From A = {1, 2, 3, 4, 5}, remove elements that also appear in B = {3, 4, 5, 6, 7}.
A \ B = {1, 2}
5
Step 5 — Verify De Morgan's LawLeft side: (A ∪ B)ᶜ = {1, 2, 3, 4, 5, 6, 7}ᶜ = {8, 9, 10}. Right side: Aᶜ ∩ Bᶜ = {6, 7, 8, 9, 10} ∩ {1, 2, 8, 9, 10} = {8, 9, 10}. Both sides yield the same set, confirming (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ.
(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ = {8, 9, 10} ✓ De Morgan's Law verified.

Comparing Set Operations

Understanding the relationships and differences among the three core operations is essential for avoiding common errors. The table below highlights the key properties, potential pitfalls, and practical interpretations of each operation.

Properties and analogues of the three fundamental set operations
PropertyUnion (∪)Intersection (∩)Complement (ᶜ)
Logical analogueOR (∨)AND (∧)NOT (¬)
Commutative?Yes: A ∪ B = B ∪ AYes: A ∩ B = B ∩ AN/A (unary)
Associative?YesYesN/A (unary)
Identity element∅ (A ∪ ∅ = A)U (A ∩ U = A)(Aᶜ)ᶜ = A (involution)
AnnihilatorU (A ∪ U = U)∅ (A ∩ ∅ = ∅)∅ᶜ = U, Uᶜ = ∅
Common errorThinking ∪ adds cardinalities (double-counting)Confusing ∩ with ∪ when using 'and' colloquiallyForgetting that complement depends on U
Database analogySQL UNIONSQL INTERSECT / INNER JOINSQL NOT IN / EXCEPT
KEY TAKEAWAY
In database systems and programming, set operations appear ubiquitously. A SQL SELECT with a WHERE clause is performing set-builder notation on a table; UNION, INTERSECT, and EXCEPT are direct implementations of ∪, ∩, and \ respectively. Mastering set identities therefore translates directly to query optimization — rewriting a complex query using De Morgan or distribution can dramatically reduce computational cost.

Connections to Advanced Theory

The three operations covered in this lesson — union, intersection, and complement — form the building blocks for far more sophisticated structures encountered in higher mathematics and theoretical computer science. Understanding these connections provides motivation and context for advanced coursework.

From basic set operations to advanced mathematics
Concept from This LessonAdvanced ExtensionWhere It Appears
Finite union / intersectionCountable & uncountable unions/intersections (⋃, ⋂ over index sets)Measure theory, topology, σ-algebras
Complement relative to URelative complement in general lattices; topological closure/interiorLattice theory, point-set topology
Boolean algebra of 𝒫(U)General Boolean algebras, Stone's representation theoremLogic, algebraic topology, digital design
Set-builder notation with predicatesComprehension axiom schema in ZFC; type theoryFoundations of mathematics, proof assistants (Lean, Coq)
Cardinality |A ∪ B| via inclusion-exclusionGeneralized inclusion-exclusion for n sets; Möbius inversionCombinatorics, probability, number theory (sieve methods)

A particularly important bridge is the Inclusion-Exclusion Principle, which generalizes the cardinality formula |A ∪ B| = |A| + |B| − |A ∩ B| to any finite number of sets. For n sets A₁, A₂, …, Aₙ, the cardinality of their union is computed by alternately adding and subtracting the cardinalities of all possible intersections. This principle has deep connections to Euler's totient function, the Principle of Inclusion-Exclusion in probability (P(A ∪ B) = P(A) + P(B) − P(A ∩ B)), and combinatorial sieve methods used in analytic number theory. In computer science, the same idea underlies the analysis of hash collisions, network reliability, and the computation of permanent of a matrix.

🔭 Looking Ahead
In subsequent lessons on relations and functions, you will see that a function f: A → B is formally defined as a specific type of subset of the Cartesian product A × B. The operations you learned here — particularly set difference and complement — will be essential for defining injections, surjections, inverse images, and equivalence classes.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why the complement of a set depends on the choice of universal set U. Give a specific example where the same set A has different complements under two different universal sets.
PROBLEM 2BASIC CALCULATION
Let U = {a, b, c, d, e, f, g, h}, A = {a, b, c, d}, B = {c, d, e, f}. Compute: (a) A ∪ B, (b) A ∩ B, (c) Aᶜ, (d) B \ A.
PROBLEM 3INTERMEDIATE
Using set identities (not element enumeration), prove that A \ (B ∩ C) = (A \ B) ∪ (A \ C) for arbitrary sets A, B, C.
PROBLEM 4APPLIED
In a survey of 200 computer science students, 130 know Python, 85 know Java, and 60 know both Python and Java. How many students know neither language? Use the inclusion-exclusion principle and express your solution using set notation.
PROBLEM 5CRITICAL THINKING
Let A, B, C be subsets of a universal set U. Prove or disprove: if A ∪ C = B ∪ C and A ∩ C = B ∩ C, then A = B.

Lesson Summary

A set is an unordered collection of distinct elements, described via roster notation or set-builder notation. The three fundamental operations are union (A ∪ B: elements in A or B), intersection (A ∩ B: elements in both A and B), and complement (Aᶜ: elements in U but not in A). These operations mirror logical connectives — OR, AND, and NOT — and together endow the power set 𝒫(U) with the structure of a Boolean algebra.

Critical identities include the commutative, associative, and distributive laws, the De Morgan's Laws ((A ∪ B)ᶜ = Aᶜ ∩ Bᶜ and (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ), and the inclusion-exclusion principle (|A ∪ B| = |A| + |B| − |A ∩ B|). These tools form the algebraic backbone for proofs, counting arguments, probability computations, database query optimization, and the axiomatic framework of modern mathematics.

Varsity Tutors • Discrete Math • Set notation and operations (union, intersection, complement)