Final review for CS2304, Mathematical Foundations of Computer Science.
Set and Ordering
I won’t repeat the basics of set theory here.
Symmetric difference: the elements that are in
Relations and Functions
- Ordered pair:
- Cartesian product:
Relations
- Binary relation: (a set of ordered pairs)
- Properties:
- Reflexivity:
- Symmetry:
- Transitivity:
Equivalence Relations and Partitions
- Equivalence relation: a relation that is reflexive, symmetric and transitive at the same time
- Equivalence class:
- Partition: a family of non-empty, mutually disjoint subsets of A that covers A
Functions
- Definition of a function: a relation F such that
- , written F(x) = y
- Special functions:
- Injective:
- Surjective:
- Bijective: both injective and surjective
Orderings
Partial Order
- Definition: a relation
satisfying: - Reflexivity:
- Antisymmetry:
- Transitivity:
- Reflexivity:
- A linear order (Total Order) is a special case of a partial order that satisfies:
- Any two elements are comparable:
- Unique maximal and minimal elements
- Hasse Diagram:
keeps only the immediate successor relation (means is the immediate successor of )
Special Elements
| Element type | Definition |
|---|---|
| Minimal | |
| Maximal | |
| Smallest | |
| Largest |
Properties:
- The largest/smallest element is always maximal/minimal, but the converse does not hold
- A finite partially ordered set always has minimal and maximal elements
Linear Extension Theorem
Linear extensions: for a finite partially ordered set , there exists a linearly ordered set such that
That is, any partial order can be extended to a linear order while preserving the original order relation. (This is actually topological sorting.)
Antichains and Chains
| Concept | Definition |
|---|---|
| Chain | Any two elements are comparable: |
| Antichain | No two elements are comparable: |
Dilworth’s Theorem
- Core result: the size of the largest antichain equals the minimum number of antichains in a partition
- Corollary:
whereis the size of the largest antichain and is the length of the longest chain
Application: the Erdős–Szekeres Lemma
Any sequence of
Cardinality
Equinumerosity
- Definition:
- Important results:
(the natural numbers and the rationals are equinumerous) (the reals are uncountable) (Cantor’s theorem)
Continuum Hypothesis
- Question: is there a cardinal
with ? - Conclusion: it can be neither proved nor disproved within the ZFC axiom system (Gödel & Cohen)
Combinatorics
Basic Counting Problem: The Balls-into-Boxes Model
The different cases of putting n balls into m boxes:
| Ball type \ Box type | No restriction | ≤1 ball per box | ≥1 ball per box |
|---|---|---|---|
| Distinct balls, distinct boxes | |||
| Identical balls, distinct boxes | |||
| Distinct balls, identical boxes | |||
| Identical balls, identical boxes |
where:
- : the falling factorial
- : Stirling numbers of the second kind (set partitions)
- : the number of ways to partition the integer n into k parts
Basic Counting Principles
Counting Subsets
- Number of subsets of an n-element set:
- Number of k-element subsets:
Counting Permutations
- Number of permutations of an n-element set:
- Permutations with constraints (multinomial coefficients):
The Binomial and Multinomial Theorems
Binomial Theorem
Corollaries:
Multinomial Theorem
Generalized Binomial Theorem (Newton)
where
Special Counting Sequences
Catalan Numbers
Definition:
Recurrence:
Applications:
- Triangulations of a convex (n+2)-gon
- Dyck paths (lattice paths that do not cross the diagonal)
- Number of valid parenthesis sequences
Stirling Numbers
Stirling numbers of the second kind (set partitions):
Stirling numbers of the first kind (permutations by cycles):
Properties:
Inclusion–Exclusion Principle
Basic Formula
Applications
Derangements:
Euler’s totient function:
Generating Functions
Ordinary Generating Functions (OGF)
Definition:
Operations on Generating Functions
| Operation | Description | Change in generating function | Change in the sequence |
|---|---|---|---|
| Addition | Add the sequences and | ||
| Scaling by a constant | Multiply the sequence by a constant | ||
| Right shift | Shift the sequence right by n positions (pad the first n with 0) | ||
| Left shift | Shift the sequence left by n positions (drop the first n terms) | ||
| Substitute | Multiply the terms by | ||
| Substitute | Take one element every terms | ||
| Differentiation | Multiply the terms by the index n | ||
| Integration | Divide the terms by | ||
| Multiplication/convolution | Convolution of two sequences |
Applications
Fibonacci sequence:
Catalan numbers:
Solving Recurrence Relations
Homogeneous Linear Recurrences
Method:
- Solve the characteristic equation:
- Build the general solution according to the roots:
- Simple root :
- Root of multiplicity :
Non-homogeneous Recurrences
General solution = homogeneous solution + particular solution (guess the particular solution from the form of )
Asymptotic Analysis
Asymptotic Notation
- f(n) = O(g(n)):
- : f=O(g) and g=O(f)
Important Asymptotic Estimates
Factorial (Stirling’s formula):
Harmonic series:
Binomial coefficients:
Graph theory
Already covered in detail in Graph Theory
(Rant: I started learning graph theory in Data Structures in the second semester of freshman year, learned it again in Circuit Theory and Discrete Mathematics in the first semester of sophomore year, and then once more in Algorithms and this math course in the second semester of sophomore year. Saturation-style learning, I guess.)
The probabilistic method
Same as above, I won’t repeat the basic concepts.
Random Variables
Definition and Distribution
- Random variable
- Discrete distribution:
Expectation and Variance
- Expectation:
- Variance:
- Linearity:
Common Distributions
| Distribution | PMF | Expectation | Variance |
|---|---|---|---|
| Bernoulli(p) | |||
| Binomial(n,p) | |||
| Geometric(p) |
Memorylessness of the Geometric Distribution
Probability Inequalities
Basic Inequalities
- Markov: for non-negative
and : - Chebyshev:
Chernoff Bounds
For independent Bernoulli(
- Upper tail:
- Lower tail:
The Probabilistic Method
By choosing objects of a specified class at random and showing that the probability of obtaining the target object is greater than zero, we prove that it exists. This is a non-constructive method.
Basic Counting Arguments
- Existence of Boolean functions: there exists an
-variable Boolean function that needs symbols to describe
Expectation Arguments
- Graph cuts: a graph with
vertices and edges has a partition with a cut - Lower bound on independent sets:
- MAXSAT: with
clauses (minimum length ), there exists an assignment satisfying clauses
Lovász Local Lemma
For events
Applications:
- A
-SAT instance is satisfiable when each variable appears times - Existence of edge-disjoint paths: a solution exists when
Random graph
Translated from the Chinese original.

