1. Sets
Definition
- A set is a collection of distinct objects
- Examples of sets:
- The set of integers, denoted by Z
- The set of non-negative integers (natural numbers), denoted by N
- The set of truth values, denoted by B={T,F}
- The set of students in this classroom
Set Membership
- The elements or members of a set are the objects comprising it
- If b is an element of a set L, then we write b∈L
- ภาษาอังกฤษอ่านว่า a member of!
Ways to Display a Set
There are two ways to display a set:
-
Explicit listing: List the elements belonging to it
- Example: B={T,F} (set of truth values)
-
Property specification: Specify the properties that characterize the elements
- Example: The set of even integers: {x∣x∈Z and xmod2=0}
- Alternative notation: {x∈Z∣xmod2=0}
- อ่านได้ว่า x is an integer where x mod 2 = 0
Set Equality
- Two sets are equal if they have the same elements
X=Y iff (∀x∈X:x∈Y) and (∀x∈Y:x∈X)
ต้องโชว์ each member in x must be in y && each member in y must be in x
Special Sets
- Empty set: A set without any element, denoted by ∅
- Finite set: A set with finitely many elements
- A set A is finite if and only if there is a one-to-one correspondence between elements of A and {1,2,…,n} for some natural number n (ยังไม่ต้องเข้าใจตอนนี้ก็ได้)
- Infinite set: A set with infinitely many elements
- Countably infinite sets: e.g., N
- Uncountably infinite sets: e.g., [0,1]
Subsets
-
Subset: A set X is a subset of a set Y, written X⊆Y, if each element of X is also an element of Y
X⊆Y iff ∀x∈X:x∈Y
-
Proper subset: X is a proper subset of Y, written X⊂Y, if X is a subset of Y but X and Y are not equal
X⊂Y iff X⊆Y and X=Y
-
Examples:
- The set of natural numbers N is a proper subset of the set of integers Z
อันนี้มีให้พิสูจน์เช่นกัน
Basic Facts about Subsets
- For any set A:
- The empty set ∅ is a subset of A: ∅⊆A
- A is a subset of itself: A⊆A
- If A⊆B and B⊆A, then A=B (USED FREQUENTLY)
2. Set Operations: Union, Difference, Intersection
Union
- The union of two sets A,B is the set of elements which belongs to at least one of them, denoted A∪B
∀x:x∈A∨x∈B⇔x∈A∪B
Intersection
- The intersection of two sets A,B is the set of elements which belongs to both of them, denoted A∩B
∀x:x∈A∧x∈B⇔x∈A∩B
Disjoint Sets
- Two sets A,B are disjoint if A∩B=∅
Set Difference
- The set difference of two sets A,B is the set of those elements in A that are not in B, denoted A∖B (or A−B)
∀x:x∈A∧x∈/B⇔x∈A∖B
A∖B=A∩B′
Laws for Set Operations
- A∪A=A
- A∩A=A
- A∪B=B∪A
- A∩B=B∩A
- (A∪B)∪C=A∪(B∪C)
- (A∩B)∩C=A∩(B∩C)
General Union and Intersection
Due to these rules, we can define:
- General union: ⋃{A1,A2,A3,…}=A1∪A2∪A3∪…
- General intersection: ⋂{A1,A2,A3,…}=A1∩A2∩A3∩…
Set Complement
Suppose there is a big set U such that both A and B are subsets of U.
- Complement of A: A=U∖A
- Complement of B: B=U∖B
Then:
- A∖B=A∩B
- A∩B=A∪B
- A∪B=A∩B
- A∪(A∩B)=A
- A∩(A∪B)=A
Distributivity Law
#MidtermExam will show up (proving question) + DeMorgan’s
- A∪(B∩C)=(A∪B)∩(A∪C)
- A∩(B∪C)=(A∩B)∪(A∩C)
DeMorgan's Laws
- A∖(B∪C)=(A∖B)∩(A∖C)
- A∖(B∩C)=(A∖B)∪(A∖C)
Proof of Distributivity Law
To prove: A∪(B∩C)=(A∪B)∩(A∪C)
We need to prove both directions:
- A∪(B∩C)⊆(A∪B)∩(A∪C)
- (A∪B)∩(A∪C)⊆A∪(B∩C)
Part 1: Consider x∈A∪(B∩C). There are two cases:
- Case 1: If x∈A, then x∈A∪B and x∈A∪C, hence x∈(A∪B)∩(A∪C)
- Case 2: If x∈B∩C, then x∈B and x∈C. Hence x∈A∪B and x∈A∪C. Therefore x∈(A∪B)∩(A∪C)
Hence A∪(B∩C)⊆(A∪B)∩(A∪C)
Part 2: Consider x∈(A∪B)∩(A∪C). So x∈A∪B and x∈A∪C.
In other words, (x∈A or x∈B) and (x∈A or x∈C).
- Case 1: If x∈A, then x∈A∪(B∩C)
- Case 2: If x∈/A, then x∈B and x∈C, i.e., x∈B∩C and hence x∈A∪(B∩C)
So in any case x∈A∪(B∩C). Hence (A∪B)∩(A∪C)⊆A∪(B∩C)
Proof of DeMorgan's Laws
มาแน่เลยว่ะ ๆ
To prove: A∖(B∪C)=(A∖B)∩(A∖C)
Let U be a set such that all sets A,B,C are subsets of U. We have:
A∖(B∪C)
=A∩(B∪C) (applying the law: X∖Y=X∩Y)
=A∩(B∩C) (DeMorgan's law for complements)
=(A∩B)∩(A∩C) (distributivity)
=(A∖B)∩(A∖C) (definition of set difference)
Exercise: Prove A∖(B∩C)=(A∖B)∪(A∖C) (EASY)
General Union
- If S is a collection of sets, then ⋃S is the set whose elements are the elements of the sets in S
Examples:
- If S={{a,b},{c},{a,d}}, then ⋃S={a,b,c,d}
- If S={{a,b},{c},{a,{d,a}}}, then ⋃S={a,b,c,{d,a}}
How about ⋂s?
The Power Set
- If S is a set, then 2S, called the power set of S, is the set of all subsets of S
Examples:
- S={a}, 2S={∅,{a}}
- S={a,b}, 2S={∅,{a},{b},{a,b}}

Partition
A partition of a set S is a set Π of subsets of S (i.e., Π⊆2S) such that:
- Each element of Π is not empty
- Distinct members of Π are disjoint
- ⋃Π=S (covers the entire set)
Example: S={a,b,c}
- Π={{a},{b,c}} is a partition of S
- A={{a},{a,b},{c}} is not a partition (overlapping sets)
- B={{a},{b,c},∅} is not a partition (contains empty set)
3. Relations and Functions
Ordered Pairs
- An ordered pair is written as (a,b) where a is the first component and b is the second
- An ordered pair (a,b) can be understood as a set {a,{a,b}}
- Similarly (b,a) as a set {b,{a,b}}
Note: {a,b}={b,a} but (a,b)=(b,a)
Cartesian Product
- The Cartesian product of two sets A,B, denoted A×B, is the set of all ordered pairs (a,b) with a∈A,b∈B
A×B={(a,b)∣a∈A,b∈B}
Examples:
- {a,b}×{a}={(a,a),(b,a)}
- The plane can be represented as a Cartesian product R×R where R is the set of all real numbers
Functions
- A map or function from a set A to a set B, denoted f:A→B, is an assignment to each element a∈A a single element, denoted by f(a), in B
Function Components:
- A is called the domain of f
- B is called the co-domain of f
- f(a) is called the image of a under f
- The range of f is denoted by f(A)={f(a)∣a∈A}
- For A′⊆A, f(A′)={f(a)∣a∈A′} is called the image of A′ under f
Example: +:N×N→N where +(1,2)=3
Function Exercises
- If A=∅, how many possible functions are there from A to B?
- If B=∅, how many functions are there from A to B?
- If A contains exactly one element, how many functions are there from A to B?
Types of Functions
- A function f:A→B is one-to-one (injective) if for any two distinct elements a,a′∈A, f(a)=f(a′)

- A function f:A→B is onto B (surjective) if B=f(A)

- A function f:A→B is a bijection between A and B if it is both one-to-one and onto B

- Let A and B be two finite sets. A and B have the same number of elements iff there is a bijection between A and B
Function Composition
- Given a function f:A→B and g:B→C, the composition f∘g:A→C is defined by:
- (f∘g)(a)=g(f(a))
Example:
- f:N×N→N where f(m,n)=m+n
- g:N→N where g(k)=2k
- (f∘g)(m,n)=2(m+n)
Relations
- A binary relation on two sets A,B is a subset of A×B
- Example: The greater or equal relation ≥ in the set of integers: R={(m,n)∣m≥n}⊆Z×Z
n-tuples and n-ary Relations
- An ordered n-tuple is written as (a1,a2,…,an) where ai is the i-th component
- The n-fold Cartesian product of sets A1,…,An, denoted by A1×⋯×An, is the set of all ordered n-tuples with ai∈Ai for i=1,…,n
- An n-ary relation on sets A1,…,An is a subset of A1×⋯×An
Terminology:
- Binary = 2-ary (double = 2-tuple)
- Ternary = 3-ary (triple = 3-tuple)
- Quaternary = 4-ary (quadruple = 4-tuple)
Functions vs Relations
- A function is a special relation
- A function from a set A to a set B is a binary relation R on A,B such that:
- For each a∈A there is exactly one ordered pair in R with first component a
Tip: How to tell if R is a function:
- There must be only one outgoing link for each node on the left-hand side
Relation Operations
-
A binary relation R⊆A×B has an inverse R−1⊆B×A defined by:
-
(b,a)∈R−1 if and only if (a,b)∈R
-
For binary relations Q⊆A×B and R⊆B×C, the composition Q∘R is defined by:
-
Q∘R={(a,c)∣∃b∈B such that (a,b)∈Q and (b,c)∈R}
Exercise: Show that if f:A→B is a bijection, then f−1 is also a bijection from B to A.
Types of Relations
For a relation R⊆A×A:
- Reflexive: if for each a∈A, (a,a)∈R (self loops)
- Symmetric: if (a,b)∈R whenever (b,a)∈R (back and forth)
- Transitive: if whenever (a,b)∈R and (b,c)∈R then (a,c)∈R
- Equivalence relation: if it is reflexive, transitive, and symmetric
Examples of relation types:
- Married relationship: symmetric
- Ancestor relationship: transitive
- Same nationality: equivalence relation
Equivalence Classes
- Let R be an equivalence relation on a set A. For each a∈A, the equivalence class of a with respect to R is:
- [a]R={b∣(a,b)∈R}
- When the relation R is understood, we simply write [a] for [a]R
Property: Let R be an equivalence relation on a set A. Then for any two elements a,b∈A, either [a]R=[b]R or [a]R,[b]R are disjoint.
- A modulo R: A/R={[a]R∣a∈A}
Theorem: Let R be an equivalence relation on a set A. Then A/R is a partition of A.
Example of Equivalence Relations
- Let Z+ be the set of positive integers
- Define an equivalence relation ∼⊆(Z+×Z+)×(Z+×Z+) as follows:
- (p,q)∼(r,s) iff ps=qr
- The ∼ is an equivalence relation characterizing the rational numbers
- The set (Z+×Z+)/∼ is the set of rational numbers
Orders
- A relation R⊆A×A is antisymmetric if whenever (a,b)∈R and a=b then (b,a)∈/R
- A relation that is reflexive, transitive and antisymmetric is called a partial order
- A partial order R⊆A×A is called a total order if for all a,b∈A, either (a,b)∈R or (b,a)∈R
Paths and Cycles
- A path from a to b in a binary relation R⊆A×A is a sequence a1,…,an,n≥1 such that:
- a=a1, b=an
- For each i∈{1,…,n−1}, (ai,ai+1)∈R
- A path a1,…,an is a cycle if a1=an and all $a_i
4. Finite Sets and Infinite Sets
Counting
- Equinumerous sets: Two sets A,B are equinumerous if there is a bijection f:A→B
- Cardinality: We say that the cardinality of A is n if A is equinumerous with the set {1,...,n}
- Countably infinite: A is countably infinite if it is equinumerous with the set of natural numbers N={0,1,2,...}
- Uncountably infinite: A is uncountably infinite if it is infinite and not equinumerous with the set of natural numbers
Think of cardinality as a way to measure "how many" elements are in a set. It's like counting, but extended to infinite sets too.
Examples and Properties
- Positive odd numbers: A={1,3,5,7,...} is countably infinite
- Can map each element to a distinct integer using f(n)=2n−1
- Positive even numbers: B={2,4,6,8,...} is countably infinite
- Can map using f(n)=2n
Key Theorems
- Every subset of a finite set is finite
- Every subset of a countably infinite set is finite or countably infinite
- The set N×N is countably infinite (using dovetailing technique)
- Union theorem: The union of countably infinite collection of countably infinite sets is again countably infinite
The dovetailing technique is like systematically traversing a grid - you can count all pairs (i,j) by going diagonally through the infinite grid.
5. Three Fundamental Proof Techniques
1. Principle of Mathematical Induction
Statement: Let A be a set of natural numbers such that:
- 0∈A
- For each natural number n, if {0,1,...,n}⊆A then n+1∈A
Then A=N
Mathematical induction is like climbing an infinite ladder - if you can get on the first rung (base case) and you can always step from one rung to the next (inductive step), then you can reach any rung.
Prove: 1+2+⋯+n=2n(n+1)
Base case: n=1: 1=21(1+1)=1 ✓
Inductive step: Assume true for n, prove for n+1:
1+2+⋯+n+(n+1)=(1+2+⋯+n)+(n+1)
=2n(n+1)+(n+1) (by induction hypothesis)
=2n(n+1)+2(n+1)=2(n+1)(n+2)
Example 2: Power Set Cardinality
Prove: For any finite set A, ∣2A∣=2∣A∣
Base case: ∣A∣=0, then A=∅, and 2A={∅}, so ∣2A∣=1=20
Inductive step: Let ∣A∣=n+1. Pick element a∈A, let B=A−{a}.
- By induction hypothesis: ∣2B∣=2n
- The power set 2A can be partitioned into:
- Sets not containing a: these are exactly 2B
- Sets containing a: these are {C∪{a}:C∈2B}
- Therefore: ∣2A∣=∣2B∣+∣2B∣=2⋅2n=2n+1
2. The Pigeonhole Principle
Statement: If A,B are finite sets and ∣A∣>∣B∣, then there is no one-to-one function from A to B
If you have more pigeons than pigeonholes, at least one pigeonhole must contain more than one pigeon.
Exercises
-
79 students, 70 chairs: Is it possible to give each student a separate chair?
- Answer: No, by pigeonhole principle since 79>70
-
Society problem: 5×106 men and 5×106+1 women. Can each woman get her own man?
- Answer: No, since there are more women than men
Proof by Induction
Base case: ∣B∣=0, so B=∅. No function f:A→B exists at all.
Inductive hypothesis: Assume true when ∣B∣≤n
Inductive step: Let ∣B∣=n+1 and ∣A∣>∣B∣. Pick a∈A.
- If another element a′∈A satisfies f(a)=f(a′), then f is not one-to-one
- Otherwise, consider g:A−{a}→B−{f(a)} that agrees with f
- Since ∣A−{a}∣=∣A∣−1>∣B∣−1=∣B−{f(a)}∣, by induction hypothesis g is not one-to-one
- Therefore f is not one-to-one
Application: Path Length Theorem
Theorem: Let R be a binary relation on a finite set A, and let a,b∈A. If there is a path from a to b in R, then there is a path of length at most ∣A∣.
Proof: If the shortest path has length >∣A∣, then by pigeonhole principle, some element repeats in the path. We can remove the cycle to get a shorter path, contradiction.
3. The Diagonalization Principle
อาจจะให้โชว์ D เฉย ๆ นะ
Statement: Let R be a binary relation on a set A, and let:
- D={a:a∈A and (a,a)∈/R} (diagonal set)
- For each a∈A: Ra={b:b∈A and (a,b)∈R} (row set)
Then D is distinct from each Ra
Imagine R as a grid/table where rows and columns are labeled with elements of A. The diagonal set D is constructed by "flipping" the main diagonal - if there's a cross, remove it; if there's no cross, add one. This new diagonal will be different from every row.
Example
Let A={1,2,3,4,5} and
R={(1,3),(2,4),(3,5),(5,1),(2,3),(1,1),(4,2),(4,4)}
Finding the sets:
- R1={1,3} (elements related to 1)
- R2={3,4} (elements related to 2)
- R3={5} (elements related to 3)
- R4={2,4} (elements related to 4)
- R5={1} (elements related to 5)
- D={2,3,5} (elements not related to themselves)
You can verify that D doesn't match any Ri.
Variations
-
Column sets: Ca={b:b∈A and (b,a)∈R}
- Would the diagonal principle still hold? (Exercise for consideration)
-
Complement diagonal: D′={a:a∈A and (a,a)∈R}
- Would the diagonal principle still hold? (Exercise for consideration)
Major Application: Uncountability of Power Set
Theorem: The set 2N is uncountably infinite
Proof by contradiction:
- Assume 2N is countably infinite
- Then there exists a bijection f:N→2N
- Define relation R={(n,m):m∈f(n)}
- By diagonalization principle, the diagonal set D={n:n∈/f(n)} is different from every Rn=f(n)
- But this means D is not in the range of f, contradicting that f is onto
- Therefore, 2N is uncountably infinite
This proof shows there are "more" subsets of natural numbers than there are natural numbers themselves - a profound result about the nature of infinity.
Summary
These three proof techniques are fundamental tools in mathematics:
- Mathematical Induction: Proves statements about all natural numbers by establishing a base case and inductive step
- Pigeonhole Principle: Shows impossibility of certain mappings when there are more objects than containers
- Diagonalization Principle: Constructs objects that differ from all objects in a given collection, often used to prove impossibility results
Each technique has its own domain of application and together they form a powerful toolkit for mathematical reasoning.
6. Alphabet and Languages
[This section would be covered in subsequent pages of the document]