Learn
Lesson · Sets, Relations, and Functions · Sets

Set Operations

Five operations, each defined by a connective from Logic and Proof. Union is ∨, intersection is ∧, complement is ¬ — which is why the set identities are the logical equivalences wearing different symbols.

A ∪ B = {x : x ∈ A ∨ x ∈ B} A ∩ B = {x : x ∈ A ∧ x ∈ B} A \ B = {x : x ∈ A ∧ x ∉ B} Ā = {x ∈ U : x ∉ A} complement, relative to a universe U
Each operation is a connective

Core ideas

What this lesson establishes

Every set operation is a logical connective applied to membership. That correspondence is the reason to have done Logic and Proof first.

1

Union is inclusive

x ∈ A ∪ B when x is in at least one. Elements in both are in the union once — a set has no multiplicities.

2

Complement needs a universe

Ā is meaningless without a stated universal set U. The complement of the even numbers is different inside ℤ and inside ℝ.

3

Difference is not symmetric

A \ B and B \ A are generally different sets. Symmetric difference A △ B is the union of the two, and is the set analogue of ⊕.

The material

The five operations

Definitions, then the correspondence with the connectives.

Definition · Union, intersection, difference

A ∪ B = {x : x ∈ A ∨ x ∈ B}, A ∩ B = {x : x ∈ A ∧ x ∈ B}, A \ B = {x : x ∈ A ∧ x ∉ B}.

Definition · Complement

Relative to a universal set U containing every set under discussion, Ā = U \ A = {x ∈ U : x ∉ A}.

Definition · Symmetric difference

A △ B = (A \ B) ∪ (B \ A) — the elements in exactly one of the two. Equivalently (A ∪ B) \ (A ∩ B).

Definition · Disjoint

A and B are disjoint when A ∩ B = ∅. A collection is pairwise disjoint when every two distinct members of it are disjoint — the condition “Equivalence Relations and Partitions” needs for partitions.

The correspondence with logic

set operation membership condition connective A ∪ B x ∈ A ∨ x ∈ B ∨ A ∩ B x ∈ A ∧ x ∈ B ∧ Ā ¬(x ∈ A) ¬ A \ B x ∈ A ∧ ¬(x ∈ B) ∧, ¬ A △ B x ∈ A ⊕ x ∈ B ⊕ A ⊆ B x ∈ A → x ∈ B →

This is not an analogy. Every set identity in “Set Identities and Proofs” is a logical equivalence from “Logical Equivalence” in Logic and Proof, applied pointwise to membership. De Morgan for sets and De Morgan for propositions are the same theorem in two notations, and knowing that halves what has to be memorised.

Theorem · Inclusion-exclusion for two sets

For finite sets, |A ∪ B| = |A| + |B| − |A ∩ B|.

Adding |A| and |B| counts every element of A ∩ B twice — once in each term — and every other element of A ∪ B once. Subtracting |A ∩ B| removes exactly the surplus.

□

“The Inclusion-Exclusion Principle” in Combinatorics and Counting generalises this to any number of sets, where the alternating signs are less obvious and the correction is larger. The two-set case is worth having by heart now.

Example · Difference is not symmetric

With A = {1, 2, 3} and B = {3, 4}: A \ B = {1, 2} and B \ A = {4}. Their union {1, 2, 4} is A △ B, and A ∩ B = {3} is exactly what △ excludes.

Interactive

Set algebra

Two expressions, one membership

Set expressions over U = {1, …, 12}Click an element to move it between the sets
selected by Aselected by B

Method

Evaluating a set expression

Translate to membership conditions, then evaluate elementwise.

1

Rewrite the expression as a membership condition

x ∈ A ∩ (B ∪ C) becomes x ∈ A ∧ (x ∈ B ∨ x ∈ C). From here it is propositional logic.

2

Decide the condition for each element in turn

With a small universe this is quick and cannot go wrong. It is also how the lab computes.

3

Watch the universe when complementing

Ā depends entirely on U. An expression mixing complements and an unstated universe is not well defined.

4

Check a boundary case

What does the expression give when A = ∅, or when A = B? Degenerate cases catch misreadings faster than general ones.

Operations

Score 0 / 0

Evaluating (A \ B) ∪ (B ∩ C)

U = {1,…,8}, A = {1,2,3,4}, B = {3,4,5,6}, C = {4,6,8}.

A \ B = {1, 2, 3, 4} minus anything in B = {1, 2} B ∩ C = {3,4,5,6} ∩ {4,6,8} = {4, 6} union = {1, 2} ∪ {4, 6} = {1, 2, 4, 6} Check element by element: 1 ∈ A, 1 ∉ B ⟹ in A\B ✓ 3 ∈ A but 3 ∈ B ⟹ not in A\B; 3 ∉ C ⟹ not in B∩C ✗ 4 ∈ A and 4 ∈ B ⟹ not in A\B; 4 ∈ B and 4 ∈ C ⟹ in B∩C ✓

Element 4 is the interesting one: it fails the first term and passes the second. Checking a few elements individually is how you catch a misplaced parenthesis, which the set-level calculation hides.

Common mistakes

1
Assuming A \ B = B \ ADifference is not symmetric. A \ B keeps what is in A only; B \ A keeps what is in B only, and those are different sets.
2
Adding cardinalities without subtracting the overlap|A ∪ B| = |A| + |B| holds only when A and B are disjoint. Otherwise the shared elements are counted twice.
3
Complementing without a universeAn expression containing Ā and no stated U is incomplete. The lab pins U = {1, …, 12} for exactly this reason.

Check your understanding

✓
Finish when you can translate any set expression into a membership condition without hesitating.

Take (A △ B) \ C and write the condition for x to belong. If you produce (x ∈ A ⊕ x ∈ B) ∧ x ∉ C, the rest of the course's set algebra is Logic and Proof in different symbols.

Note: A △ B is associative and every element is its own inverse under it, which makes the subsets of U a group under symmetric difference. That structure is why △ behaves like addition modulo 2, the same connection ⊕ had in Logic and Proof.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.