Introduction

A set is an unordered collection of distinct objects, called its elements or members. Sets are the common language of discrete mathematics: relations and functions are sets of ordered pairs, a graph is a pair of sets, an event in probability is a set of outcomes, a formal language is a set of strings, and a database relation is a set of tuples.

The topics are the notation, the algebra of set operations, the size of finite sets built from other sets, and the distinction between countable and uncountable infinite sets, which matters in the theory of computation.

Prerequisites

  • None formally. The connectives of Propositional Logic (¬,∧,∨\neg, \land, \lor) are mirrored by complement, intersection and union.

Core concepts

Notation and conventions

  • x∈Ax \in A: xx is an element of AA; x∉Ax \notin A: it is not.
  • Roster form {2,3,5,7}\{2, 3, 5, 7\}; set-builder form {x∈Z∣0<x<10, x prime}\{x \in \mathbb{Z} \mid 0 < x < 10,\ x \text{ prime}\}.
  • Order and repetition do not matter: {1,2,2,3}={3,1,2}\{1, 2, 2, 3\} = \{3, 1, 2\}. A collection where repetition matters is a multiset.
  • Standard sets. Z\mathbb{Z} integers, Q\mathbb{Q} rationals, R\mathbb{R} reals. Convention in these notes: N={0,1,2,…}\mathbb{N} = \{0, 1, 2, \ldots\} includes 0 (as in Rosen); Z+={1,2,3,…}\mathbb{Z}^{+} = \{1, 2, 3, \ldots\}. Some textbooks start N\mathbb{N} at 1, so read each question's definition.
  • The empty set ∅={}\emptyset = \{\} has no elements. ∅≠{∅}\emptyset \ne \{\emptyset\}: the second set has one element.
  • ∣A∣|A| is the cardinality (number of elements) of a finite set AA.

Subsets and equality

  • A⊆BA \subseteq B (subset) means every element of AA is in BB: ∀x (x∈A→x∈B)\forall x\,(x \in A \to x \in B).
  • A⊂BA \subset B or A⊊BA \subsetneq B (proper subset) means A⊆BA \subseteq B and A≠BA \ne B. Some books use ⊂\subset for ⊆\subseteq; these notes write ⊊\subsetneq when properness matters.
  • A=BA = B if and only if A⊆BA \subseteq B and B⊆AB \subseteq A. This "double inclusion" is the standard way to prove two sets equal.
  • For every set AA: ∅⊆A\emptyset \subseteq A and A⊆AA \subseteq A. (∅⊆A\emptyset \subseteq A is vacuously true.)
  • Membership and subset differ: for A={1,{1}}A = \{1, \{1\}\}, both 1∈A1 \in A and {1}∈A\{1\} \in A hold, and {1}⊆A\{1\} \subseteq A also holds; {{1}}⊆A\{\{1\}\} \subseteq A holds too.

Set operations

Fix a universal set UU containing every set under discussion.

OperationNotationDefinition
UnionA∪BA \cup B{x∣x∈A∨x∈B}\{x \mid x \in A \lor x \in B\}
IntersectionA∩BA \cap B{x∣x∈A∧x∈B}\{x \mid x \in A \land x \in B\}
DifferenceA−BA - B or A∖BA \setminus B{x∣x∈A∧x∉B}\{x \mid x \in A \land x \notin B\}
ComplementA‾\overline{A} or AcA^cU−AU - A
Symmetric differenceA⊕BA \oplus B or A△BA \triangle B(A−B)∪(B−A)(A - B) \cup (B - A)

AA and BB are disjoint if A∩B=∅A \cap B = \emptyset. A partition of a non-empty set SS is a collection of non-empty, pairwise disjoint subsets whose union is SS (partitions correspond to equivalence relations; see Relations).

Venn diagrams of the basic set operations
Figure 1. Shaded regions for A∪BA \cup B, A∩BA \cap B, A−BA - B, A‾\overline{A} and A⊕BA \oplus B inside a universal set UU.

Set identities

Each identity corresponds to a law of propositional logic (replace ∪\cup by ∨\lor, ∩\cap by ∧\land, complement by ¬\neg).

LawIdentity
IdentityA∪∅=AA \cup \emptyset = A, A∩U=AA \cap U = A
DominationA∪U=UA \cup U = U, A∩∅=∅A \cap \emptyset = \emptyset
IdempotentA∪A=AA \cup A = A, A∩A=AA \cap A = A
ComplementationA‾‾=A\overline{\overline{A}} = A
Commutative, associativefor ∪\cup, ∩\cap and ⊕\oplus
DistributiveA∩(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)
De MorganA∪B‾=A‾∩B‾\overline{A \cup B} = \overline{A} \cap \overline{B}, A∩B‾=A‾∪B‾\overline{A \cap B} = \overline{A} \cup \overline{B}
AbsorptionA∪(A∩B)=AA \cup (A \cap B) = A, A∩(A∪B)=AA \cap (A \cup B) = A
ComplementA∪A‾=UA \cup \overline{A} = U, A∩A‾=∅A \cap \overline{A} = \emptyset
DifferenceA−B=A∩B‾A - B = A \cap \overline{B}

Useful facts about symmetric difference: A⊕A=∅A \oplus A = \emptyset, A⊕∅=AA \oplus \emptyset = A, and A⊕B=CA \oplus B = C if and only if B=A⊕CB = A \oplus C (so ⊕\oplus has cancellation). Union and intersection have no such cancellation: A∪B=A∪CA \cup B = A \cup C does not imply B=CB = C.

Power set

The power set P(A)\mathcal{P}(A) (also 2A2^A) is the set of all subsets of AA. If ∣A∣=n|A| = n, then

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

because each of the nn elements is independently in or out of a subset. Example: P({a,b})={∅,{a},{b},{a,b}}\mathcal{P}(\{a, b\}) = \{\emptyset, \{a\}, \{b\}, \{a, b\}\}. Note P(∅)={∅}\mathcal{P}(\emptyset) = \{\emptyset\}, which has one element, and ∣P(P(∅))∣=2|\mathcal{P}(\mathcal{P}(\emptyset))| = 2.

Cartesian product

The Cartesian product A×B={(a,b)∣a∈A,b∈B}A \times B = \{(a, b) \mid a \in A, b \in B\} is a set of ordered pairs: (a,b)=(c,d)(a, b) = (c, d) if and only if a=ca = c and b=db = d. In general A×B≠B×AA \times B \ne B \times A, and

∣A×B∣=∣A∣⋅∣B∣,∣A1×⋯×Ak∣=∣A1∣⋯∣Ak∣.|A \times B| = |A| \cdot |B|, \qquad |A_1 \times \cdots \times A_k| = |A_1| \cdots |A_k|.

A×∅=∅A \times \emptyset = \emptyset. A relation from AA to BB is any subset of A×BA \times B, so there are 2∣A∣∣B∣2^{|A||B|} relations from AA to BB.

Sizes of unions: inclusion-exclusion

For finite sets A,B,CA, B, C:

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣,|A \cup B| = |A| + |B| - |A \cap B|,
∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣.|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|.

The general nn-set formula and its counting applications are in Counting.

Related identities: ∣A−B∣=∣A∣−∣A∩B∣|A - B| = |A| - |A \cap B|, ∣A⊕B∣=∣A∣+∣B∣−2∣A∩B∣|A \oplus B| = |A| + |B| - 2|A \cap B|, and ∣A‾∣=∣U∣−∣A∣|\overline{A}| = |U| - |A|.

Countable and uncountable sets

Two sets have the same cardinality if there is a bijection between them (see Functions). A set is countable if it is finite or has the same cardinality as N\mathbb{N} (countably infinite); otherwise it is uncountable.

CountableUncountable
N,Z,Q\mathbb{N}, \mathbb{Z}, \mathbb{Q}, N×N\mathbb{N} \times \mathbb{N}R\mathbb{R}, any interval (a,b)(a, b) with a<ba < b
Σ∗\Sigma^*, all finite strings over a finite alphabetP(N)\mathcal{P}(\mathbb{N}), the set of all languages over a non-empty alphabet
A countable union of countable setsThe set of all functions N→{0,1}\mathbb{N} \to \{0, 1\}
The set of all programs (Turing machines)The set of all real numbers in [0,1][0, 1]

Cantor's theorem: for every set AA, there is no surjection from AA onto P(A)\mathcal{P}(A), so ∣A∣<∣P(A)∣|A| < |\mathcal{P}(A)|. Proof sketch (diagonal argument): given any f:A→P(A)f : A \to \mathcal{P}(A), the set D={a∈A∣a∉f(a)}D = \{a \in A \mid a \notin f(a)\} differs from every f(a)f(a) at the element aa, so DD is not in the range of ff.

Consequence for computing: there are countably many programs but uncountably many languages over {0,1}\{0, 1\}, so some languages are not recognised by any program. This is the counting argument behind undecidability.

Worked examples

Example 1: an identity by algebra

Simplify (A∪B)∩C‾‾∪B\overline{(A \cup B) \cap \overline{C}} \cup B.

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

Union with BB: (A‾∩B‾)∪B∪C=((A‾∪B)∩(B‾∪B))∪C=A‾∪B∪C(\overline{A} \cap \overline{B}) \cup B \cup C = ((\overline{A} \cup B) \cap (\overline{B} \cup B)) \cup C = \overline{A} \cup B \cup C.

Example 2: inclusion-exclusion

Among the integers 1 to 100, how many are divisible by 2, 3 or 5?

Let A2,A3,A5A_2, A_3, A_5 be the multiples of 2, 3 and 5. Then ∣A2∣=50|A_2| = 50, ∣A3∣=33|A_3| = 33, ∣A5∣=20|A_5| = 20, ∣A2∩A3∣=⌊100/6⌋=16|A_2 \cap A_3| = \lfloor 100/6 \rfloor = 16, ∣A2∩A5∣=10|A_2 \cap A_5| = 10, ∣A3∩A5∣=6|A_3 \cap A_5| = 6, ∣A2∩A3∩A5∣=3|A_2 \cap A_3 \cap A_5| = 3.

50+33+20−16−10−6+3=74.50 + 33 + 20 - 16 - 10 - 6 + 3 = 74 .

So 74 are divisible by at least one of them and 100−74=26100 - 74 = 26 by none.

Example 3: power sets and products

Let A={1,2,3}A = \{1, 2, 3\}, B={x,y}B = \{x, y\}. Then ∣A×B∣=6|A \times B| = 6, ∣P(A×B)∣=26=64|\mathcal{P}(A \times B)| = 2^6 = 64 (the number of relations from AA to BB), and ∣P(A)×P(B)∣=8⋅4=32|\mathcal{P}(A) \times \mathcal{P}(B)| = 8 \cdot 4 = 32.

Example 4: a tricky membership question

S={∅,{∅}}S = \{\emptyset, \{\emptyset\}\}. Which are true? (i) ∅∈S\emptyset \in S; (ii) ∅⊆S\emptyset \subseteq S; (iii) {∅}∈S\{\emptyset\} \in S; (iv) {∅}⊆S\{\emptyset\} \subseteq S; (v) {{∅}}⊆S\{\{\emptyset\}\} \subseteq S; (vi) ∣P(S)∣=4|\mathcal{P}(S)| = 4.

All six are true. (i) and (iii) list the two elements; (ii) holds for every set; (iv) holds because the single element ∅\emptyset of {∅}\{\emptyset\} is in SS; (v) holds because {∅}∈S\{\emptyset\} \in S; (vi) because ∣S∣=2|S| = 2.

Example 5: symmetric difference

A={1,2,3,4}A = \{1, 2, 3, 4\}, B={3,4,5}B = \{3, 4, 5\}. A⊕B={1,2,5}A \oplus B = \{1, 2, 5\}, and ∣A∣+∣B∣−2∣A∩B∣=4+3−4=3|A| + |B| - 2|A \cap B| = 4 + 3 - 4 = 3. Check cancellation: A⊕{1,2,5}={3,4,5}=BA \oplus \{1, 2, 5\} = \{3, 4, 5\} = B.

Important properties and observations

  • A⊆BA \subseteq B is equivalent to each of A∪B=BA \cup B = B, A∩B=AA \cap B = A, A−B=∅A - B = \emptyset, and B‾⊆A‾\overline{B} \subseteq \overline{A}.
  • A−B≠B−AA - B \ne B - A in general; difference is neither commutative nor associative.
  • P(A∩B)=P(A)∩P(B)\mathcal{P}(A \cap B) = \mathcal{P}(A) \cap \mathcal{P}(B), but only P(A)∪P(B)⊆P(A∪B)\mathcal{P}(A) \cup \mathcal{P}(B) \subseteq \mathcal{P}(A \cup B) (equality only when one of A,BA, B contains the other).
  • A×(B∪C)=(A×B)∪(A×C)A \times (B \cup C) = (A \times B) \cup (A \times C) and A×(B∩C)=(A×B)∩(A×C)A \times (B \cap C) = (A \times B) \cap (A \times C).
  • An infinite subset of a countable set is countably infinite; a superset of an uncountable set is uncountable.

GATE examination perspective

  • Identity MCQs. Reduce with A−B=A∩B‾A - B = A \cap \overline{B} and De Morgan, or test with a three-set Venn diagram (8 regions) by checking which regions each side shades.
  • Counting with sets. Inclusion-exclusion for "divisible by" and "at least one" questions; complements for "none of".
  • Power-set and product sizes. 2n2^n subsets, 2mn2^{mn} relations from an mm-set to an nn-set.
  • Countability. Expect statements such as "the set of all languages over {0,1}\{0, 1\} is countable" (false) or "the set of all Turing machines is countable" (true).
  • Trap: ∅\emptyset versus {∅}\{\emptyset\}, and ∈\in versus ⊆\subseteq.
  • Trap: whether N\mathbb{N} contains 0 changes answers about smallest elements and counts. Check the definition given.

Summary

Sources

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Sections 2.1 (Sets), 2.2 (Set Operations) and 2.5 (Cardinality of Sets).

Next steps