evan's notes
cal 3discreteodeenv systems
中文

On this page

  • Sets and membership
  • Example: membership
  • The empty set
  • Subsets and set inclusion
  • Example: comparing two sets
  • Elements and subsets are different
  • Common number sets
  • Two ways to define a set
  • Definition by extension
  • Definition by comprehension
  • Example: natural and odd numbers
  • Example: rational numbers
  • Set equality
  • Example: two forms of the odd integers
  • Why not every condition defines a set
  • Non-example: Russell's paradox
  • Set operations
  • Union
  • Intersection
  • Difference
  • Complement
  • Symmetric difference
  • Set identities and Venn diagrams
  • Example: a distributive law
  • Common set identities
  • Example: proving an identity algebraically
  • Cartesian products
  • Power sets

Discrete Structures

§1 Sets

Evan Luo · Sep 1, 2026

Discrete Structures

§1 Sets

Evan LuoSep 1, 2026

13 min read

Sets and membership

A set is a collection of distinct objects. The objects inside it are called elements or members. We write the elements between braces, such as {1,2,3}\{1,2,3\}{1,2,3}.

Example: membership

Let

A={1,2,3}.A=\{1,2,3\}. A={1,2,3}.

The symbol ∈\in∈ is the membership symbol. Read x∈Ax\in Ax∈A as “xxx is an element of AAA.” The symbol ∉\notin∈/ is the non-membership symbol and means “is not an element of.” Therefore,

1∈Aand4∉A.1\in A \qquad\text{and}\qquad 4\notin A. 1∈Aand4∈/A.

The empty set

The empty set is the set with no elements. Its symbol is ∅\varnothing∅, and it can also be written as empty braces:

∅={}.\varnothing=\{\}. ∅={}.

Since the empty set has no elements, x∉∅x\notin\varnothingx∈/∅ for every object xxx. In particular,

∅∉∅.\varnothing\notin\varnothing. ∅∈/∅.

This says the empty set is not an element of itself. It is different from {∅}\{\varnothing\}{∅}, which is a set containing one element—the empty set:

∅∈{∅}.\varnothing\in\{\varnothing\}. ∅∈{∅}.

Subsets and set inclusion

The symbol ⊆\subseteq⊆ is the subset symbol. Read

A⊆BA\subseteq B A⊆B

as “AAA is a subset of BBB” or “AAA is included in BBB.” This relationship is called set inclusion. It means that every element of AAA is also an element of BBB.

Equality is allowed, so every set is a subset of itself:

A⊆A.A\subseteq A. A⊆A.

A proper subset leaves out at least one element. The symbol ⊂\subset⊂ means “is a proper subset of.” Read

A⊂BA\subset B A⊂B

as “AAA is a proper subset of BBB.” It means A⊆BA\subseteq BA⊆B but A≠BA\neq BA=B, so the two sets are not equal.

You may also see A⊊BA\subsetneq BA⊊B. The symbol ⊊\subsetneq⊊ always makes “subset but not equal” explicit. The symbol ⊂\subset⊂ is sometimes used differently between books, but in these notes it means proper subset.

Example: comparing two sets

Let

A={1,2,3}andB={1,2,3,4}.A=\{1,2,3\} \qquad\text{and}\qquad B=\{1,2,3,4\}. A={1,2,3}andB={1,2,3,4}.

Then

A⊆B.A\subseteq B. A⊆B.

This is true because every element of AAA also appears in BBB. It is a proper subset, A⊂BA\subset BA⊂B, because 444 belongs to BBB but not to AAA.

The empty set is a subset of every set:

∅⊆A.\varnothing\subseteq A. ∅⊆A.

For this to be false, we would need an element of ∅\varnothing∅ that is missing from AAA. There are no elements in ∅\varnothing∅, so that can never happen. In particular, ∅⊆∅\varnothing\subseteq\varnothing∅⊆∅.

Elements and subsets are different

The symbols ∈\in∈ and ⊆\subseteq⊆ describe different relationships:

ExpressionRead asWhat it checks
x∈Ax\in Ax∈Axxx is an element of AAAwhether one object is a member of AAA
B⊆AB\subseteq AB⊆ABBB is a subset of AAAwhether every element of the set BBB is also an element of AAA

That means

∅⊆A\varnothing\subseteq A ∅⊆A

is always true, while

∅∈A\varnothing\in A ∅∈A

is true only when the empty set itself appears as an element of AAA.

Sometimes both relationships are true. If

A={1,2,{1,2}},A=\{1,2,\{1,2\}\}, A={1,2,{1,2}},

then

{1,2}∈A\{1,2\}\in A {1,2}∈A

because {1,2}\{1,2\}{1,2} appears as one element of AAA. We also have

{1,2}⊆A\{1,2\}\subseteq A {1,2}⊆A

because both 111 and 222 are elements of AAA.

Common number sets

SymbolNameNumbers it contains
N\mathbb NNnatural numbers0,1,2,3,…0,1,2,3,\ldots0,1,2,3,…
N+\mathbb N^+N+positive natural numbers1,2,3,…1,2,3,\ldots1,2,3,…
Z\mathbb ZZintegers…,−2,−1,0,1,2,…\ldots,-2,-1,0,1,2,\ldots…,−2,−1,0,1,2,…
Q\mathbb QQrational numbersfractions such as 12\frac1221​, −23-\frac23−32​, and 555
R\mathbb RRreal numbersevery number on the real number line

In these notes, 000 is included in N\mathbb NN. Some books start N\mathbb NN at 111, so always check which convention is being used.

Each number set is a subset of the next one:

N+⊆N⊆Z⊆Q⊆R.\mathbb N^+\subseteq\mathbb N\subseteq\mathbb Z\subseteq\mathbb Q\subseteq\mathbb R. N+⊆N⊆Z⊆Q⊆R.

Viewed as points on the number line, N\mathbb NN and Z\mathbb ZZ are discrete: their values are separated. For example, the integer after 222 is 333; there is no integer between them.

The real number line is continuous instead. Between any two different real numbers, there are always more real numbers, so the values do not come in separate steps.

Two ways to define a set

Definition by extension

A definition by extension, also called roster notation, lists the elements between braces:

A={1,2,3}.A=\{1,2,3\}. A={1,2,3}.

Order does not matter, and writing an element more than once does not change the set:

{1,2,3}={3,2,1}={1,1,2,3}.\{1,2,3\} = \{3,2,1\} = \{1,1,2,3\}. {1,2,3}={3,2,1}={1,1,2,3}.

A set only records whether an element belongs to it. It does not record the element's position or how many times it was written.

Definition by comprehension

A definition by comprehension, also called set-builder notation, describes the common property of the elements:

A={x∈U∣P(x)}.A=\{x\in U\mid P(x)\}. A={x∈U∣P(x)}.

Here:

  • xxx represents a possible element;
  • UUU is the universe, or the set from which xxx is chosen;
  • the vertical bar ∣\mid∣ is read as “such that”;
  • P(x)P(x)P(x) is the property or condition that xxx must satisfy.

Example: natural and odd numbers

The natural numbers can be defined as the nonnegative integers:

N={x∈Z∣x≥0}.\mathbb N=\{x\in\mathbb Z\mid x\ge0\}. N={x∈Z∣x≥0}.

The condition x≥0x\ge0x≥0 means “xxx is greater than or equal to zero.” In other words, start with the integers, then keep the nonnegative values.

The odd natural numbers can be written by extension,

O={1,3,5,7,…},O=\{1,3,5,7,\ldots\}, O={1,3,5,7,…},

or by comprehension,

O={2k+1∣k∈N}.O=\{2k+1\mid k\in\mathbb N\}. O={2k+1∣k∈N}.

As kkk runs through 0,1,2,3,…0,1,2,3,\ldots0,1,2,3,…, the expression 2k+12k+12k+1 gives 1,3,5,7,…1,3,5,7,\ldots1,3,5,7,….

Example: rational numbers

A rational number is any number that can be written as a fraction of two integers:

Q={ab  |  a,b∈Z, b≠0}.\mathbb Q= \left\{ \frac ab \;\middle|\; a,b\in\mathbb Z, \ b\neq0 \right\}. Q={ba​​a,b∈Z, b=0}.

The condition b≠0b\neq0b=0 means the denominator cannot be zero. An integer such as 555 is rational because 5=515=\frac515=15​.

The same rational number can have many fraction forms:

12=24=−3−6.\frac12=\frac24=\frac{-3}{-6}. 21​=42​=−6−3​.

We usually write a rational number in reduced form: the denominator is positive, and the numerator and denominator share no positive factor except 111. In other words, their greatest common divisor (GCD) is 111. For example,

2−3=−23,\frac{2}{-3}=-\frac23, −32​=−32​,

and the form on the right follows the positive-denominator convention.

Set equality

The principle of extensionality says that two sets are equal when they contain exactly the same elements. Their order and the way they were defined do not matter.

The double-inclusion method proves that A=BA=BA=B by showing both directions:

A⊆BandB⊆A.A\subseteq B \qquad\text{and}\qquad B\subseteq A. A⊆BandB⊆A.

The first direction shows that AAA has no element missing from BBB. The second shows that BBB has no element missing from AAA.

Example: two forms of the odd integers

Consider

O={2k+1∣k∈Z}O=\{2k+1\mid k\in\mathbb Z\} O={2k+1∣k∈Z}

and

A={2ℓ−1∣ℓ∈Z}.A=\{2\ell-1\mid \ell\in\mathbb Z\}. A={2ℓ−1∣ℓ∈Z}.

Both descriptions produce all odd integers. To prove O=AO=AO=A, we show both inclusions.

Take any x∈Ox\in Ox∈O. Then x=2k+1x=2k+1x=2k+1 for some integer kkk. Rewrite it as

x=2k+1=2(k+1)−1.x=2k+1=2(k+1)-1. x=2k+1=2(k+1)−1.

Since k+1k+1k+1 is an integer, xxx has the form used in AAA. Therefore,

O⊆A.O\subseteq A. O⊆A.

Now take any x∈Ax\in Ax∈A. Then x=2ℓ−1x=2\ell-1x=2ℓ−1 for some integer ℓ\ellℓ. Rewrite it as

x=2ℓ−1=2(ℓ−1)+1.x=2\ell-1=2(\ell-1)+1. x=2ℓ−1=2(ℓ−1)+1.

Since ℓ−1\ell-1ℓ−1 is an integer, xxx has the form used in OOO. Therefore,

A⊆O.A\subseteq O. A⊆O.

Both directions are true, so O=AO=AO=A.

Why not every condition defines a set

The unrestricted comprehension principle would allow any condition P(x)P(x)P(x) to create a set {x∣P(x)}\{x\mid P(x)\}{x∣P(x)}. Russell's paradox shows why this does not work.

Non-example: Russell's paradox

Suppose we try to define

R={x∣x is a set and x∉x}.R=\{x\mid x\text{ is a set and }x\notin x\}. R={x∣x is a set and x∈/x}.

In words, RRR would contain every set that is not an element of itself. Under this proposed rule, ∅\varnothing∅ would qualify because ∅∉∅\varnothing\notin\varnothing∅∈/∅.

For comparison, some versions of set theory allow a self-containing set called a Quine atom, written Q={Q}Q=\{Q\}Q={Q}. Since Q∈QQ\in QQ∈Q, it would not qualify for RRR.

Now ask whether RRR is an element of itself:

  • If R∈RR\in RR∈R, then RRR must satisfy its own condition, so R∉RR\notin RR∈/R.
  • If R∉RR\notin RR∈/R, then RRR satisfies the defining condition, so by definition R∈RR\in RR∈R.

Either answer gives the opposite answer. The symbol   ⟺  \iff⟺ means “if and only if,” so we can write the contradiction as

R∈R  ⟺  R∉R.R\in R\iff R\notin R. R∈R⟺R∈/R.

This is Russell's paradox.

The safe version is restricted comprehension, called separation in formal set theory. Start with an already defined universe UUU, then choose the elements that satisfy P(x)P(x)P(x):

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

This creates a subset of UUU instead of assuming that every condition creates a set. Here, UUU is the universal set for the current problem—not one set containing every set that exists.

Set operations

Set operations build new sets from sets we already have. Unless stated otherwise, all complements are taken relative to a fixed universe UUU.

Let AAA and BBB be subsets of UUU. For a concrete example, take

A={1,3,5}andB={1,2,3}.A=\{1,3,5\} \qquad\text{and}\qquad B=\{1,2,3\}. A={1,3,5}andB={1,2,3}.

Union

The union contains everything that belongs to at least one of the two sets:

A∪B={x∈U∣x∈A or x∈B}.A\cup B=\{x\in U\mid x\in A\text{ or }x\in B\}. A∪B={x∈U∣x∈A or x∈B}.

The word “or” is inclusive here: an element may belong to AAA, to BBB, or to both. In the example,

A∪B={1,2,3,5}.A\cup B=\{1,2,3,5\}. A∪B={1,2,3,5}.
A ∪ B Venn diagramEvery point in A or B, including their overlap, is shaded.ABU
Union. Every region inside A or B is included, including the overlap.

Intersection

The intersection contains only the elements shared by both sets:

A∩B={x∈U∣x∈A and x∈B}.A\cap B=\{x\in U\mid x\in A\text{ and }x\in B\}. A∩B={x∈U∣x∈A and x∈B}.

Therefore,

A∩B={1,3}.A\cap B=\{1,3\}. A∩B={1,3}.
A ∩ B Venn diagramOnly the overlap shared by A and B is shaded.ABU
Intersection. Only the region shared by A and B is included.

Difference

The set difference A∖BA\setminus BA∖B keeps the elements of AAA that are not in BBB:

A∖B={x∈U∣x∈A and x∉B}.A\setminus B=\{x\in U\mid x\in A\text{ and }x\notin B\}. A∖B={x∈U∣x∈A and x∈/B}.

Difference depends on the order:

A∖B={5},B∖A={2}.A\setminus B=\{5\}, \qquad B\setminus A=\{2\}. A∖B={5},B∖A={2}.
A ∖ B Venn diagramThe part of A outside B is shaded.ABU
Difference. Keep the part of A that does not overlap B.

Complement

The complement of AAA contains everything in UUU that is outside AAA:

A‾=U∖A={x∈U∣x∉A}.\overline A=U\setminus A =\{x\in U\mid x\notin A\}. A=U∖A={x∈U∣x∈/A}.

The universe matters. For A={1,3,5}A=\{1,3,5\}A={1,3,5} and the convention N={0,1,2,…}\mathbb N=\{0,1,2,\ldots\}N={0,1,2,…},

U=N⟹A‾={0,2,4,6,7,8,…}.U=\mathbb N \quad\Longrightarrow\quad \overline A=\{0,2,4,6,7,8,\ldots\}. U=N⟹A={0,2,4,6,7,8,…}.

If the universe is instead R\mathbb RR, then

A‾=(−∞,1)∪(1,3)∪(3,5)∪(5,∞).\overline A =(-\infty,1)\cup(1,3)\cup(3,5)\cup(5,\infty). A=(−∞,1)∪(1,3)∪(3,5)∪(5,∞).

The notation A‾\overline AA is not universal. Depending on the course or context, the complement may be written AcA^cAc or U∖AU\setminus AU∖A.

A̅ Venn diagramEverything in the universe U outside A is shaded.ABU
Complement. Everything in the universe U outside A is included.

Symmetric difference

The symmetric difference contains the elements that belong to exactly one of AAA and BBB:

A△B={x∈U∣x belongs to exactly one of A and B}.A\mathbin\triangle B =\{x\in U\mid x\text{ belongs to exactly one of }A\text{ and }B\}. A△B={x∈U∣x belongs to exactly one of A and B}.

For the example,

A△B={2,5}.A\mathbin\triangle B=\{2,5\}. A△B={2,5}.

Some sources write symmetric difference as A⊕BA\oplus BA⊕B. Neither symbol is universal, so its meaning should be stated when the context is unclear.

It has two useful equivalent forms:

A△B=(A∪B)∖(A∩B)=(A∖B)∪(B∖A).A\mathbin\triangle B =(A\cup B)\setminus(A\cap B) =(A\setminus B)\cup(B\setminus A). A△B=(A∪B)∖(A∩B)=(A∖B)∪(B∖A).
A △ B Venn diagramThe non-overlapping parts of A and B are shaded.ABU
Symmetric difference. Keep the regions in exactly one of A and B, but not their overlap.

Set identities and Venn diagrams

A set identity is an equality that is true for every allowed choice of its sets. Venn diagrams divide the universe into all possible membership regions. If two expressions shade exactly the same regions, then they contain exactly the same elements, so the expressions are equal.

This is the same double-inclusion idea used earlier. If expressions XXX and YYY shade the same regions, then every x∈Xx\in Xx∈X also lies in the region for YYY, giving X⊆YX\subseteq YX⊆Y. The same argument in reverse gives Y⊆XY\subseteq XY⊆X. Therefore, X=YX=YX=Y.

Example: a distributive law

Let AAA, BBB, and CCC be subsets of UUU. Union distributes over intersection:

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

On the left, we take all of AAA together with the part shared by BBB and CCC. On the right, a point must belong to both A∪BA\cup BA∪B and A∪CA\cup CA∪C. If it is not in AAA, it must be in both BBB and CCC. Both sides therefore select the same regions.

A ∪ (B ∩ C)

A ∪ (B ∩ C), animated Venn diagramThe animation shades B, then C, keeps their intersection, adds A, and finishes with their union.ABCU
1. Shade B2. Shade C3. Keep B ∩ C4. Add A5. Take the union

(A ∪ B) ∩ (A ∪ C)

(A ∪ B) ∩ (A ∪ C), animated Venn diagramThe animation builds A union B, then A union C, overlays them, and keeps the region common to both.ABCU
1. Build A ∪ B2. Build A ∪ C3. Overlay both unions4. Keep their common part5. Same final region
At the final step, both expressions shade all of A together with the overlap of B and C. Because the shaded regions match, the sets are equal.

Intersection also distributes over union:

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).

Common set identities

The following identities hold for all sets AAA, BBB, and CCC inside a fixed universe UUU.

LawIdentities
IdentityA∩U=AA\cap U=AA∩U=A and A∪∅=AA\cup\varnothing=AA∪∅=A
IdempotentA∪A=AA\cup A=AA∪A=A and A∩A=AA\cap A=AA∩A=A
AbsorptionA∪(A∩B)=AA\cup(A\cap B)=AA∪(A∩B)=A and A∩(A∪B)=AA\cap(A\cup B)=AA∩(A∪B)=A
AssociativeA∪(B∪C)=(A∪B)∪CA\cup(B\cup C)=(A\cup B)\cup CA∪(B∪C)=(A∪B)∪C and A∩(B∩C)=(A∩B)∩CA\cap(B\cap C)=(A\cap B)\cap CA∩(B∩C)=(A∩B)∩C
DistributiveA∪(B∩C)=(A∪B)∩(A∪C)A\cup(B\cap C)=(A\cup B)\cap(A\cup C)A∪(B∩C)=(A∪B)∩(A∪C) and 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)
Double complementA‾‾=A\overline{\overline A}=AA=A
De MorganA∪B‾=A‾∩B‾\overline{A\cup B}=\overline A\cap\overline BA∪B=A∩B and A∩B‾=A‾∪B‾\overline{A\cap B}=\overline A\cup\overline BA∩B=A∪B
ComplementA∪A‾=UA\cup\overline A=UA∪A=U and A∩A‾=∅A\cap\overline A=\varnothingA∩A=∅

Example: proving an identity algebraically

Set identities can be combined like algebraic rules. To prove

A∪(B∩C)‾=(C‾∪B‾)∩A‾,\overline{A\cup(B\cap C)} =(\overline C\cup\overline B)\cap\overline A, A∪(B∩C)​=(C∪B)∩A,

start with the left-hand side:

A∪(B∩C)‾=A‾∩(B∩C)‾De Morgan’s law=A‾∩(B‾∪C‾)De Morgan’s law=(C‾∪B‾)∩A‾commutativity.\begin{aligned} \overline{A\cup(B\cap C)} &=\overline A\cap\overline{(B\cap C)} &&\text{De Morgan's law}\\ &=\overline A\cap(\overline B\cup\overline C) &&\text{De Morgan's law}\\ &=(\overline C\cup\overline B)\cap\overline A &&\text{commutativity.} \end{aligned} A∪(B∩C)​​=A∩(B∩C)​=A∩(B∪C)=(C∪B)∩A​​De Morgan’s lawDe Morgan’s lawcommutativity.​

A filled square ■\blacksquare■, or QED (short for the Latin phrase meaning “which was to be demonstrated”), marks that a proof is complete.

Cartesian products

The Cartesian product is an external operation: its elements are ordered pairs rather than elements of either original set. It changes the universe of discourse.

A×B={(a,b)∣a∈A and b∈B}.A\times B=\{(a,b)\mid a\in A\text{ and }b\in B\}. A×B={(a,b)∣a∈A and b∈B}.

Order matters inside each pair, so A×BA\times BA×B is generally different from B×AB\times AB×A.

For

A={1,2,3}andB={6,7},A=\{1,2,3\} \qquad\text{and}\qquad B=\{6,7\}, A={1,2,3}andB={6,7},

we pair every element of AAA with every element of BBB:

A×B={(1,6),(1,7),(2,6),(2,7),(3,6),(3,7)}.A\times B =\{(1,6),(1,7),(2,6),(2,7),(3,6),(3,7)\}. A×B={(1,6),(1,7),(2,6),(2,7),(3,6),(3,7)}.

There are 3⋅2=63\cdot2=63⋅2=6 pairs. The notation ∣A∣|A|∣A∣ means the cardinality of AAA, or the number of elements it contains. If AAA and BBB are finite, then

∣A×B∣=∣A∣ ∣B∣.|A\times B|=|A|\,|B|. ∣A×B∣=∣A∣∣B∣.

The Cartesian plane is the product of the real numbers with themselves:

R2=R×R={(x,y)∣x,y∈R}.\mathbb R^2=\mathbb R\times\mathbb R =\{(x,y)\mid x,y\in\mathbb R\}. R2=R×R={(x,y)∣x,y∈R}.

Power sets

The power set of AAA, written P(A)\mathcal P(A)P(A), is the set of every subset of AAA:

P(A)={X∣X⊆A}.\mathcal P(A)=\{X\mid X\subseteq A\}. P(A)={X∣X⊆A}.

For A={1,2,3}A=\{1,2,3\}A={1,2,3},

P(A)={∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}.\mathcal P(A)= \left\{ \varnothing, \{1\},\{2\},\{3\}, \{1,2\},\{1,3\},\{2,3\}, \{1,2,3\} \right\}. P(A)={∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}.

Each element of AAA has two choices when forming a subset: include it or leave it out. A set with nnn elements therefore has 2n2^n2n subsets:

∣P(A)∣=2∣A∣.|\mathcal P(A)|=2^{|A|}. ∣P(A)∣=2∣A∣.

The empty set has one subset—itself—so

P(∅)={∅}.\mathcal P(\varnothing)=\{\varnothing\}. P(∅)={∅}.

The power set of the empty set is not empty; it contains the empty set as its one element.

Source: https://notes.ohevan.com/notes/discrete-structures/01-sets

© 2026 Evan Luo. All rights reserved.

Back to Discrete Structures

0 reads

·Last edited Sep 3, 2026
  • newsletter

  • about me

  • sponsor

© 2026 Evan Luo. All rights reserved.