Evanalysis
2.1Embedded interactionEstimated reading time: 14 min

2.1 Sets and set operations

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

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 x is an element of a set AA, we write xAx ∈ A. If x is not an element of AA, we write xAx ∉ A.

Examples:

  • {1, 2, 3} is a set.
  • {Hong Kong Island, Kowloon, New Territories} is a set.
  • 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(xAxB).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 ABA \subset B;
  2. show BAB \subset A.

Common mistake

Do not confuse equal sets with equal descriptions

{1, 2, 3} and {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 ABA \subset B to mean “every element of AA is in BB”. Some books write ABA \subseteq B for that idea and reserve ABA \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:

{xSP(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,

{nZn 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 {xP(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\} and \{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
UnionABA \cup Belements in AA or in BB
IntersectionABA \cap Belements in both AA and BB
DifferenceABA \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 EAE \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:

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

Solution

Why the complement needs a universal set

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
  • AB=BAA \cup B = B \cup A
  • A(BC)=(AB)CA \cup (B \cup C) = (A \cup B) \cup C
  • AA=AA \cup A = A
  • A(BC)=(AB)(AC)A \cap (B \cup C) = (A \cap B) \cup (A \cap C)
  • A(BC)=(AB)(AC)A \cup (B \cap C) = (A \cup B) \cap (A \cup C)
  • (AB)c=AcBc(A \cup B)^c = A^c \cap B^c
  • (AB)c=AcBc(A \cap B)^c = A^c \cup B^c
  • (Ac)c=A(A^c)^c = A
  • AAc=A \cap A^c = \varnothing
  • AAc=EA \cup A^c = E
  • ABA \subset B if and only if AB=BA \cup B = B
  • ABA \subset B if and only if AB=AA \cap B = A
  • ABA \subset B if and only if BcAcB^c \subset A^c

The key proof method is element chasing. For example:

xA(BC)    xA and (xB or xC)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

(xA and xB) or (xA and xC),(x \in A \text{ and } x \in B) \text{ or } (x \in A \text{ and } x \in C),

and therefore to

x(AB)(AC).x \in (A \cap B) \cup (A \cap C).

Proof

Guided proof: why ABA \subset B implies AB=BA \cup B = B

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) with aAa \in A and bBb \in B. Order matters: (a, b) and (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 n-fold product AnA^n is the set of all n-tuples with entries in AA. This is just the repeated Cartesian product of AA with itself.

Power sets

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

If AA has n elements, then 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 A0,1A → {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, ABA \sqcup B is “AA with tag 1” together with “BB with tag 2”.

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 x;
  2. rewrite xx \in each side into logical conditions;
  3. simplify those conditions until both sides say the same thing.

Worked example

Prove A(BC)=(AB)CA \cap (B \setminus C) = (A \cap B) \setminus C

Start with

xA(BC).x \in A \cap (B \setminus C).

This means:

  • xAx \in A,
  • xBx \in B,
  • xCx \notin C.

But that is exactly the condition for

x(AB)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(BC)A \subset (B \cup C) means every element of AA lies in at least one of BB or CC. It does not say that ABA \subset B, and it does not say that ACA \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 worksheet conditions are best read as region instructions, not as vague pictures.

ConditionWhat the diagram must show
ABA \subset B, CBC \subset B, and AC=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.
ABA \cap B \ne \varnothing, ACA \cap C \ne \varnothing, BCB \cap C \ne \varnothing, and ABC=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(BC)A \subset (B \cap C) and BCB \subset CSince BCB \subset C, the intersection BCB \cap C is just BB. Thus AA lies inside BB, and BB lies inside CC.
A(BC)A \subset (B \cup C), not ABA \subset B, and not ACA \subset CNo point of AA is outside BCB \cup C, but AA must have at least one point in CBC \setminus B and at least one point in BCB \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=AB|A \times B| = |A|\,|B|,
  • P(A)=2A|P(A)| = 2^{|A|},
  • AB=A+BAB|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| and |B|.

Worked example

Count a union and a power set

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

Then

AB=6+52=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

222=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,

SH=102=8.|S \cup H| = 10 - 2 = 8.

By inclusion-exclusion,

SH=S+HSH=7+68=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 ABA \subseteq B, start with an arbitrary element x in AA. Then use the definition of AA to deduce enough information to show that the same x lies in BB. Because x 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

Complement is not the same as difference

AcA^c means “everything outside AA in the chosen universe”. ABA \setminus B means “the part of AA that is not in BB”. They are related, but not the same.

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

Quick check

If A=a,b,cA = {a, b, c} and B=b,c,dB = {b, c, d}, what is ABA \cap B?

Keep only the elements that belong to both sets.

Solution

Answer

Quick check

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

Ask what the complement is supposed to be taken inside.

Solution

Answer

Quick check

Ten students go hiking. Seven use sunscreen, six wear a hat, and two use neither. How many use both?

Translate the two students using neither into the size of the union first.

Solution

Answer

Quick check

If ABA \subset B, what do ABA \cup B and ABA \cap B simplify to?

Use the absorption laws from the theorem above.

Solution

Answer

Quick check

Suppose A(BC)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

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 live explorer lets you move elements in and out of A and B and watch the resulting operations update immediately.

Set A

Set B

Union

{1, 2, 3, 4}

Intersection

{2, 4}

Difference A \ B

{1}

Section mastery checkpoint

Answer each question correctly to complete this section checkpoint. Correct progress: 0%.

Skills: sets, venn-diagrams, inclusion-exclusion

Ten students go hiking. Seven use sunscreen, six wear a hat, and two use neither. How many use both sunscreen and a hat?

Attempts used: 0

Attempts remaining: Unlimited attempts

Preview does not consume an attempt.

Submit records a graded attempt.

  • Use SH=S+HSH|S \cup H| = |S| + |H| - |S \cap H|.

Skills: sets, venn-diagrams, subset-witnesses

Suppose A(BC)A \subset (B \cup C), but AA is not a subset of BB and not a subset of CC. Which statement must be true?

Attempts used: 0

Attempts remaining: Unlimited attempts

Preview does not consume an attempt.

Submit records a graded attempt.

  • AA not contained in BB means there is an element of AA outside BB.

Prerequisites

This section can be read on its own.

Key terms in this unit

Premium learning add-ons

Core notes stay free. Advanced exercises, video explanations, and premium exports are available through paid plans.