Reference & Explorer

Set Theory

Properties, operations, and laws — from first principles to De Morgan's theorem. Use the interactive explorer to build intuition.

What is a Set?

A set is an unordered collection of distinct elements. Order doesn't matter; duplicates don't exist.

Core Concept

Definition

A set groups distinct objects (elements) with no inherent ordering. Two sets are equal if and only if they contain exactly the same elements.

A = {1, 2, 3}  =  {3, 1, 2}
Notation

Membership

Use to denote that an element belongs to a set, and for non-membership.

2 ∈ {1,2,3}  ✓
5 ∉ {1,2,3}  ✓
Size

Cardinality

The cardinality |A| is the number of elements in a set. Infinite sets (like ℕ) have infinite cardinality. The empty set has cardinality 0.

|{a, b, c}| = 3
|∅| = 0
Containment

Subsets

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

{1,2} ⊆ {1,2,3}  ✓
{1,2} ⊂ {1,2,3}  ✓
Builder Notation

Set-Builder Form

Describe a set by a rule rather than listing elements. Read the vertical bar as "such that."

{x | x ∈ ℤ, x > 0}
= {1, 2, 3, ...}
Power

Power Set

The power set P(A) is the set of ALL subsets of A, including ∅ and A itself. If |A| = n, then |P(A)| = 2ⁿ.

P({1,2}) =
{∅, {1}, {2}, {1,2}}

Key Properties at a Glance

Extensionality
Sets are defined entirely by their members — two sets with the same elements are identical, regardless of how they were described.
A = B ↔
∀x(x∈A ↔ x∈B)
No Duplicates
An element either belongs to a set or it doesn't. Listing it twice has no effect: {1,1,2} = {1,2}.
{a,a,b} = {a,b}
No Ordering
Sets have no inherent sequence. {a,b} and {b,a} are the same set. (For ordered pairs, use tuples.)
{a,b} = {b,a}
Subset Reflexivity
Every set is a subset of itself. This is always true — there is no element in A that isn't in A.
A ⊆ A
Empty Set
∅ is a subset of every set. Since it has no elements, the condition "every element of ∅ is in B" is vacuously true.
∅ ⊆ A (for all A)

Set Operations

The fundamental ways to combine and transform sets. Each has a precise definition and a visual intuition via Venn diagrams.

A ∪ B

Union

All elements that are in A, or in B, or in both. The combined collection with no duplicates.

{1,2} ∪ {2,3} = {1,2,3}
A ∩ B

Intersection

Only the elements that appear in both A and B. The overlap region.

{1,2,3} ∩ {2,3,4} = {2,3}
A \ B

Difference

Elements in A that are not in B. Also written A − B. Asymmetric — order matters.

{1,2,3} \ {2,3,4} = {1}
Aᶜ

Complement

All elements in the universal set U that are not in A. Requires a defined universe.

U={1..5}, A={1,2}
Aᶜ = {3,4,5}
A △ B

Symmetric Difference

Elements in A or B but not both. Equivalent to (A∪B) \ (A∩B). The XOR of sets.

{1,2,3} △ {2,3,4} = {1,4}
A × B

Cartesian Product

All ordered pairs (a,b) where a∈A and b∈B. Forms the basis of relations and functions.

{1,2}×{a,b} =
{(1,a),(1,b),(2,a),(2,b)}

Formal Definitions

Union
An element is in A ∪ B precisely when it belongs to at least one of the sets.
A ∪ B =
{x | x∈A ∨ x∈B}
Intersection
An element is in A ∩ B precisely when it belongs to both sets simultaneously.
A ∩ B =
{x | x∈A ∧ x∈B}
Difference
An element is in A \ B when it's in A but excluded from B.
A \ B =
{x | x∈A ∧ x∉B}
Sym. Difference
In exactly one of the two sets — not in their intersection.
A △ B =
(A∪B) \ (A∩B)

Interactive Explorer

Edit the sets below and click an operation to see the result visualized.

Comma-separated values (numbers or letters)
Comma-separated values (numbers or letters)
Union
A ∪ B
All elements from A and B combined — no duplicates.
Result

Laws & Identities

These algebraic laws hold for all sets A, B, C within a universal set U.

Commutativity
Union is commutativeA ∪ B = B ∪ A
Intersection is commutativeA ∩ B = B ∩ A
Associativity
Union is associative(A ∪ B) ∪ C = A ∪ (B ∪ C)
Intersection is associative(A ∩ B) ∩ C = A ∩ (B ∩ C)
Distributivity
∩ distributes over ∪A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
∪ distributes over ∩A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
De Morgan's Laws
Complement of union(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ
Complement of intersection(A ∩ B)ᶜ = Aᶜ ∪ Bᶜ
Identity Laws
Union with empty setA ∪ ∅ = A
Intersection with universeA ∩ U = A
Union with universeA ∪ U = U
Intersection with empty setA ∩ ∅ = ∅
Complement Laws
Complement union (excluded middle)A ∪ Aᶜ = U
Complement intersectionA ∩ Aᶜ = ∅
Double complement(Aᶜ)ᶜ = A
Complement of universeUᶜ = ∅
Complement of empty set∅ᶜ = U
Idempotent & Absorption Laws
Union idempotentA ∪ A = A
Intersection idempotentA ∩ A = A
Union absorptionA ∪ (A ∩ B) = A
Intersection absorptionA ∩ (A ∪ B) = A

Special Sets

Canonical sets that appear throughout mathematics and computer science.

Empty Set
Contains no elements. The unique set with cardinality 0. A subset of every set.
∅ = {}  |  |∅| = 0
U
Universal Set
The set of all objects under consideration in a given context. Defines the domain for complements.
Context-dependent
Natural Numbers
The counting numbers. Some definitions include 0; others start at 1. Convention varies by field.
{0, 1, 2, 3, ...} or {1, 2, 3, ...}
Integers
All whole numbers: positive, negative, and zero. ℕ ⊂ ℤ.
{..., -2, -1, 0, 1, 2, ...}
Rational Numbers
Numbers expressible as a ratio p/q where p,q ∈ ℤ and q ≠ 0. ℤ ⊂ ℚ.
1/2, -3/4, 7, 0.333...
Real Numbers
The complete number line, including irrationals like π and √2. ℚ ⊂ ℝ.
π, √2, e, -1.5, 0
Complex Numbers
Numbers of the form a + bi where i = √(−1). ℝ ⊂ ℂ.
3 + 2i, -i, 5
P(A)
Power Set
The set of all subsets of A. Always has 2^|A| elements. P(∅) = {∅}.
P({a}) = {∅, {a}}

Number Set Hierarchy

ℕ  ⊂  ℤ  ⊂  ℚ  ⊂  ℝ  ⊂  ℂ
Natural ⊂ Integer ⊂ Rational ⊂ Real ⊂ Complex

Quick Quiz

Test your understanding. 8 questions covering definitions, operations, and laws.

Cheat Sheet

A compact reference for all notation and key identities.

Membership & Relations

x ∈ Ax is an element of A
x ∉ Ax is not an element of A
A ⊆ BA is a subset of B
A ⊂ BA is a proper subset of B
A = BA and B have same elements
|A|Cardinality (size) of A

Operations

A ∪ BUnion: in A or B (or both)
A ∩ BIntersection: in both A and B
A \ BDifference: in A, not in B
AᶜComplement: in U, not in A
A △ BSym. diff: in exactly one
A × BCartesian product of A and B
P(A)Power set: all subsets of A

Key Identities

A ∪ ∅ = AIdentity (union)
A ∩ U = AIdentity (intersection)
A ∪ Aᶜ = UExcluded middle
A ∩ Aᶜ = ∅Non-contradiction
(Aᶜ)ᶜ = ADouble complement
A ∪ A = AIdempotent

De Morgan's Laws

(A∪B)ᶜ= Aᶜ ∩ Bᶜ
(A∩B)ᶜ= Aᶜ ∪ Bᶜ

Special Sets

Empty set
Natural numbers
Integers
Rational numbers
Real numbers
Complex numbers