Evanalysis
2.1Estimated reading time: 22 min

2.1 Sets and set operations

Build the language of membership, subset proofs, and standard set constructions that later chapters repeatedly rely on.

Course contents

Sets are the basic objects that let us talk about collections without constantly repeating the same description. In this course, sets are not a side topic. They are the language behind logic, functions, relations, and the later number constructions.

If the notation here feels unfamiliar, that is normal. The point of this unit is to make the language precise enough that later chapters can use it freely.

Sets, membership, and equality

Definition

A set

A set is a collection of things.

If xx is an element of a set AA, we write x∈Ax ∈ A. If xx is not an element of AA, we write x∉Ax ∉ A.

Examples:

  • {1,2,3}\{1, 2, 3\} is a set.
  • {Hong Kong Island, Kowloon, New Territories} is a set.
  • ∅\varnothing is the empty set, the set with no elements.

The same object may be written in different ways, but a set is determined only by its elements.

Theorem

Extensionality

Two sets are equal if and only if they have exactly the same elements.

In symbols:

A=B  ⟺  ∀x (x∈A↔x∈B).A = B \iff \forall x\, (x \in A \leftrightarrow x \in B).

This is the rule that makes set equality practical. To prove A=BA = B, the standard method is to prove both inclusions:

  1. show A⊂BA \subset B;
  2. show B⊂AB \subset A.

Common mistake

Do not confuse equal sets with equal descriptions

{1,2,3}\{1, 2, 3\} and {3,2,1}\{3, 2, 1\} are the same set, because they have the same elements. The order of listing does not matter.

Common mistake

Subset notation varies across books

This course uses A⊂BA \subset B to mean “every element of AA is in BB”. Some books write A⊆BA \subseteq B for that idea and reserve A⊂BA \subset B for strict subset. Always check the local convention.

Set-builder notation and bounded predicates

After predicate logic, the most common way to define a set is to start with a known set and then keep exactly the elements satisfying a condition:

{x∈S∣P(x)}.\{x \in S \mid P(x)\}.

This notation should be read carefully. The symbol before the vertical bar tells you where the variable is allowed to live; the predicate after the bar tells you which of those allowed elements survive. For example,

{n∈Z∣n is even}\{n \in \mathbb{Z} \mid n \text{ is even}\}

is the set of even integers.

Common mistake

Do not ignore the ambient set

The expression {x∣P(x)}\{x \mid P(x)\} is often convenient shorthand, but the rigorous version is bounded inside a set already under discussion. This prevents the definition from pretending that every verbal description automatically creates a safe mathematical object.

Common mistake

Sets are not multisets

A set remembers whether an object is present, not how many times it was listed. Thus {1,1,2,3}\{1,1,2,3\} and {1,2,3}\{1,2,3\} describe the same set, even though they would be different multisets.

Building new sets

Once we know some sets, we usually want to build more. The standard operations do exactly that.

OperationSymbolDefinition
UnionA∪BA \cup Belements in AA or in BB
IntersectionA∩BA \cap Belements in both AA and BB
DifferenceA∖BA \setminus Belements in AA but not in BB
ComplementAcA^celements outside AA in a chosen universal set

The complement depends on a universal set EE. In this unit we usually assume all sets live inside some fixed EE, so AcA^c means E∖AE \setminus A.

Worked example

Track elements through several set operations

Let

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

and take the universal set

E={1,2,3,4,5}.E = \{1, 2, 3, 4, 5\}.

Then:

  • A∪B={1,2,3,4}A \cup B = \{1, 2, 3, 4\}
  • A∩B={2,4}A \cap B = \{2, 4\}
  • A∖B={1}A \setminus B = \{1\}
  • B∖A={3}B \setminus A = \{3\}
  • Ac={3,5}A^c = \{3, 5\}
  • (A∪B)c={5}(A \cup B)^c = \{5\}

AcA^c is not an intrinsic property of AA alone. It depends on what counts as “everything” in the current discussion. That is why the universal set has to be understood first.

Why the identities are true

The set laws in this unit are not memorized by magic. They are proved by tracking one element at a time.

Theorem

Basic algebra of sets

For sets AA, BB, and CC:

  • A∪∅=AA \cup \varnothing = A
  • A∪B=B∪AA \cup B = B \cup A
  • A∪(B∪C)=(A∪B)∪CA \cup (B \cup C) = (A \cup B) \cup C
  • A∪A=AA \cup A = A
  • A∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C)
  • A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C)
  • (A∪B)c=Ac∩Bc(A \cup B)^c = A^c \cap B^c
  • (A∩B)c=Ac∪Bc(A \cap B)^c = A^c \cup B^c
  • (Ac)c=A(A^c)^c = A
  • A∩Ac=∅A \cap A^c = \varnothing
  • A∪Ac=EA \cup A^c = E
  • A⊂BA \subset B if and only if A∪B=BA \cup B = B
  • A⊂BA \subset B if and only if A∩B=AA \cap B = A
  • A⊂BA \subset B if and only if Bc⊂AcB^c \subset A^c

The key proof method is element chasing. For example:

x∈A∩(B∪C)  ⟺  x∈A and (x∈B or x∈C)x \in A \cap (B \cup C) \iff x \in A \text{ and } (x \in B \text{ or } x \in C)

which is equivalent to

(x∈A and x∈B) or (x∈A and x∈C),(x \in A \text{ and } x \in B) \text{ or } (x \in A \text{ and } x \in C),

and therefore to

x∈(A∩B)∪(A∩C).x \in (A \cap B) \cup (A \cap C).

Proof: why A⊂BA \subset B implies A∪B=BA \cup B = B

Assume A⊂BA \subset B.

To show A∪B=BA \cup B = B, it is enough to show both inclusions.

First, if x∈A∪Bx \in A \cup B, then x∈Ax \in A or x∈Bx \in B. If x∈Ax \in A, then x∈Bx \in B because A⊂BA \subset B. So in either case x∈Bx \in B, which gives A∪B⊂BA \cup B \subset B.

Conversely, if x∈Bx \in B, then automatically x∈A∪Bx \in A \cup B. So B⊂A∪BB \subset A \cup B.

Hence A∪B=BA \cup B = B.

Proof: a conditional distributive identity

The statement

(A∩B)∪C=A∩(B∪C)(A \cap B) \cup C = A \cap (B \cup C)

holds if and only if C⊂AC \subset A.

For the forward direction, assume C⊂AC \subset A. If xx belongs to the left side, then either x∈A∩Bx \in A \cap B, or x∈Cx \in C. In the second case the inclusion C⊂AC \subset A gives x∈Ax \in A, so in either case x∈Ax \in A and x∈B∪Cx \in B \cup C. Thus the left side is contained in the right side. Conversely, if x∈A∩(B∪C)x \in A \cap (B \cup C), then x∈Ax \in A and either x∈Bx \in B or x∈Cx \in C. In the first case x∈A∩Bx \in A \cap B; in the second case x∈Cx \in C. Hence xx is in the left side, proving equality.

For the reverse direction, assume the displayed equality and take any c∈Cc \in C. Then c∈(A∩B)∪Cc \in (A \cap B) \cup C, so equality puts cc in A∩(B∪C)A \cap (B \cup C). In particular c∈Ac \in A. Therefore every element of CC belongs to AA, which is exactly C⊂AC \subset A. Equivalently, if one had c∈C∖Ac \in C \setminus A, that element would belong to the left side but not the right side, giving a counterexample to the equality.

Proof: symmetric difference is associative

The symmetric difference is

A△B=(A∖B)∪(B∖A).A \mathbin{\triangle} B=(A\setminus B)\cup(B\setminus A).

For every element xx,

x∈A△B  ⟺  (x∈A and x∉B) or (x∉A and x∈B).x\in A\mathbin{\triangle}B \iff (x\in A\text{ and }x\notin B)\text{ or }(x\notin A\text{ and }x\in B).

Thus membership means that exactly one of AA and BB contains xx. Applying the same rule once more, xx belongs to (A△B)△C(A\mathbin{\triangle}B)\mathbin{\triangle}C exactly when an odd number of the three statements x∈Ax\in A, x∈Bx\in B, and x∈Cx\in C is true: the first symmetric difference records whether the first two statements have odd parity, and the second toggles that parity when x∈Cx\in C. The expression A△(B△C)A\mathbin{\triangle}(B\mathbin{\triangle}C) has the same odd-parity condition, with the grouping reversed. Therefore

(A△B)△C=A△(B△C).(A\mathbin{\triangle}B)\mathbin{\triangle}C =A\mathbin{\triangle}(B\mathbin{\triangle}C).

This is a membership proof, so it does not depend on a particular Venn diagram.

Proof: complement reverses inclusion

Let A,B⊆EA,B\subseteq E and assume A⊆BA\subseteq B. For x∈E∖Bx\in E\setminus B, if x∈Ax\in A then the inclusion would imply x∈Bx\in B, a contradiction. Thus x∈E∖Ax\in E\setminus A and Bc⊆AcB^c\subseteq A^c. The common universe EE ensures that both complements compare elements of the same ambient set.

Counterexample mode

Union cannot be cancelled

The implication A⊆B⇒A∪C⊆B∪CA\subseteq B\Rightarrow A\cup C\subseteq B\cup C holds, but its converse fails. Take A={1}A=\{1\}, B=∅B=\varnothing, C={1}C=\{1\}. Then both unions equal {1}\{1\} while A⊈BA\nsubseteq B. Adding CC conceals the witness 1. One valid repair is to assume also A∩C=∅A\cap C=\varnothing: every x∈Ax\in A then belongs to B∪CB\cup C but not to CC, so it belongs to BB.

Other set constructions

The course also uses a few larger constructions that are still built from the same language.

Cartesian products

A×BA \times B is the set of ordered pairs (a,b)(a, b) with a∈Aa \in A and b∈Bb \in B. Order matters: (a,b)(a, b) and (b,a)(b, a) are different unless a=ba = b.

If ∣A∣=5|A| = 5 and ∣B∣=3|B| = 3, then ∣A×B∣=15|A \times B| = 15.

R×R=R2R \times R = R^2 is the Cartesian plane.

Finite products

The nn-fold product AnA^n is the set of all nn-tuples with entries in AA. This is just the repeated Cartesian product of AA with itself.

Power sets

P(A)P(A) is the set of all subsets of AA.

If AA has nn elements, then P(A)P(A) has 2n2^n elements. A useful way to think about this is the indicator-function viewpoint: every subset of AA can be encoded by a function A→{0,1}A → \{0, 1\}.

For example,

P({a,b})={∅,{a},{b},{a,b}}.P(\{a, b\}) = \{\varnothing, \{a\}, \{b\}, \{a, b\}\}.

Disjoint union

Sometimes two sets may overlap as raw collections, but we still want to keep track of where each element came from. The disjoint union does that by tagging the elements with their origin.

Informally, A⊔BA \sqcup B is “AA with tag 1” together with “BB with tag 2”.

Counterexample: product distributivity can fail

There need not be a bijection between

A∪(B×C)and(A∪B)×(A∪C).A \cup (B \times C) \quad\text{and}\quad (A \cup B) \times (A \cup C).

Take A={0,1}A = \{0,1\} and B=C=∅B=C=\varnothing. The left set is AA, so it has two elements. The right set is A×AA \times A, so it has four ordered pairs. Their cardinalities differ, and therefore no bijection exists in this example.

How to prove a set identity carefully

At this stage of the course, a set identity should be read as a statement about membership, not as a picture to be memorized.

The standard proof pattern is:

  1. take an arbitrary element xx;
  2. rewrite x∈x \in each side into logical conditions;
  3. simplify those conditions until both sides say the same thing.

Worked example

Prove A∩(B∖C)=(A∩B)∖CA \cap (B \setminus C) = (A \cap B) \setminus C

Start with

x∈A∩(B∖C).x \in A \cap (B \setminus C).

This means:

  • x∈Ax \in A,
  • x∈Bx \in B,
  • x∉Cx \notin C.

But that is exactly the condition for

x∈(A∩B)∖C.x \in (A \cap B) \setminus C.

Since the reasoning can be read in either direction, the two sets are equal.

This is the same idea used for De Morgan’s laws, distributive laws, and later proofs about relations and number constructions.

Reading Venn diagrams correctly

Venn diagrams are useful for organizing a situation, but the proof still comes from membership conditions. A diagram can suggest that a region is empty, inside another region, or split into several pieces; the written argument must then say which inclusion, disjointness condition, or counting equation that picture represents.

For three sets, a statement such as A⊂(B∪C)A \subset (B \cup C) means every element of AA lies in at least one of BB or CC. It does not say that A⊂BA \subset B, and it does not say that A⊂CA \subset C. Keeping those possibilities separate is a good test of whether the diagram is being read logically rather than visually only.

Worked example

Translate four Venn conditions into regions

Assume AA, BB, and CC are non-empty sets. The following common practice conditions are best read as region instructions, not as vague pictures.

ConditionWhat the diagram must show
A⊂BA \subset B, C⊂BC \subset B, and A∩C=∅A \cap C = \varnothingBoth AA and CC sit inside BB, but they do not overlap each other. The set BB may still have points outside both of them.
A∩B≠∅A \cap B \ne \varnothing, A∩C≠∅A \cap C \ne \varnothing, B∩C≠∅B \cap C \ne \varnothing, and A∩B∩C=∅A \cap B \cap C = \varnothingEach pair overlaps, but the central triple-overlap region is empty. The three pairwise overlaps must be separate regions.
A⊂(B∩C)A \subset (B \cap C) and B⊂CB \subset CSince B⊂CB \subset C, the intersection B∩CB \cap C is just BB. Thus AA lies inside BB, and BB lies inside CC.
A⊂(B∪C)A \subset (B \cup C), not A⊂BA \subset B, and not A⊂CA \subset CNo point of AA is outside B∪CB \cup C, but AA must have at least one point in C∖BC \setminus B and at least one point in B∖CB \setminus C.

The fourth line is the easiest one to misread. It does not merely say that AA touches both circles. It says that AA is completely covered by BB and CC, while still failing to be contained in either one alone.

Counting finite sets

The language of sets also controls counting.

For finite sets:

  • ∣A×B∣=∣A∣ ∣B∣|A \times B| = |A|\,|B|,
  • ∣P(A)∣=2{∣A∣}|P(A)| = 2^\{|A|\},
  • ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|.

The last formula matters because elements in the intersection are counted twice if you simply add ∣A∣|A| and ∣B∣|B|.

Worked example

Count a union and a power set

Suppose ∣A∣=6|A| = 6, ∣B∣=5|B| = 5, and ∣A∩B∣=2|A \cap B| = 2.

Then

∣A∪B∣=6+5−2=9.|A \cup B| = 6 + 5 - 2 = 9.

Now let S={a,b,c}S = \{a,b,c\}. Each element either belongs to a subset or does not, so there are

2⋅2⋅2=23=82 \cdot 2 \cdot 2 = 2^3 = 8

possible subsets. Hence ∣P(S)∣=8|P(S)| = 8.

Worked example

A Venn-diagram count without drawing the diagram

Ten students go hiking. Seven use sunscreen, six wear a hat, and two use no sun protection.

Let SS be the sunscreen set and HH the hat set. Since two students use neither form of protection,

∣S∪H∣=10−2=8.|S \cup H| = 10 - 2 = 8.

By inclusion-exclusion,

∣S∩H∣=∣S∣+∣H∣−∣S∪H∣=7+6−8=5.|S \cap H| = |S| + |H| - |S \cup H| = 7 + 6 - 8 = 5.

So five students use both sunscreen and a hat.

A checklist for subset proofs

Subset proofs are common enough that they should become routine.

To prove A⊆BA \subseteq B, start with an arbitrary element xx in AA. Then use the definition of AA to deduce enough information to show that the same xx lies in BB. Because xx was arbitrary, the conclusion applies to every element of AA.

This direct-proof pattern is exactly what later chapters reuse for relations, orders, and equivalence classes.

Common mistakes

Common mistake

A complement is a difference relative to the universe

For A⊆EA\subseteq E, the complement Ac=E∖AA^c=E\setminus A consists of the elements inside the chosen universe EE but outside AA. In contrast, A∖BA\setminus B consists of the elements inside AA but outside BB. A complement is therefore a set difference whose left operand is the universe, not the part outside the universe.

Common mistake

The universal set cannot be ignored

If you write a complement, you must know what universe you are working in. Otherwise the symbol c^c is ambiguous.

Common mistake

Order matters in products

A×BA \times B and B×AB \times A usually contain different ordered pairs. This is why products are the correct language for functions and relations.

Quick checks

Checkpoint

Why is AcA^c not defined until a universal set is chosen?

Ask what the complement is supposed to be taken inside.

Solution · Answer

Because the same set has different complements in different universes.

Checkpoint

If A⊂BA \subset B, what do A∪BA \cup B and A∩BA \cap B simplify to?

Use the absorption laws from the theorem above.

Solution · Answer

A∪B=BA \cup B = B and A∩B=AA \cap B = A.

Checkpoint

Suppose A⊂(B∪C)A \subset (B \cup C), but AA is not a subset of BB and not a subset of CC. Which two parts of AA must be non-empty?

Turn each failed subset statement into an existential statement.

Solution · Answer

There must be at least one element of AA in C∖BC \setminus B, and at least one element of AA in B∖CB \setminus C. The condition A⊂(B∪C)A \subset (B \cup C) rules out any element of AA outside both BB and CC.

Why this matters later

This unit is the first place where the course starts building the later number systems in a disciplined way.

  • N2N^2 is used to construct the integers.
  • Equivalence classes are later used to construct the rationals.
  • Relations on one set become the language for orders and classes.
  • Power sets and products reappear whenever we talk about families of subsets or tuples.

Read and try

Compare one pair of sets

The worked example compares membership choices in A and B with the resulting operations.

Set A

Set B

Union

{1, 2, 3, 4}

Intersection

{2, 4}

Difference A \ B

{1}

Practice

Work out your answer, then check it. You can revise and try again.

Loading…

Prerequisites

This section can be read on its own.

Key terms in this unit