Reference notes.
Discrete mathematics studies mathematical structures that are fundamentally discrete rather than continuous. It forms the theoretical foundation for computer science, cryptography, and algorithm design.
Logic
Propositional Logic
Propositions are declarative statements that are either true or false:
- “The sky is blue” (true)
- "" (false)
Logical connectives combine propositions:
| Symbol | Name | Meaning |
|---|---|---|
| AND | Both true | |
| OR | At least one true | |
| NOT | Negation | |
| IMPLIES | If…then | |
| IFF | If and only if |
Truth tables enumerate all possible truth values for compound propositions.
Logical equivalences are fundamental identities:
- De Morgan’s Laws: and
- Double negation:
- Contrapositive:
A tautology is always true (e.g. ). A contradiction is always false (e.g. ).
Predicate Logic
Predicates are statements containing variables: ” is even”
Quantifiers express scope:
- Universal (): “for all” — means is true for every in the domain
- Existential (): “there exists” — means is true for at least one in the domain
Nested quantifiers combine multiple quantifiers:
- Over (or ): — for every , there exists a such that
Negating quantified statements:
Proof Methods
See Mathematical Proofs for detailed coverage of:
- Direct proof
- Proof by contradiction
- Proof by contrapositive
- Mathematical induction
Set Theory
Basic Concepts
A set is an unordered collection of distinct objects (elements).
Notation:
- Set membership: ( is in ), ( is not in )
- Roster notation:
- Set-builder notation:
Special sets:
- Empty set: or
- Universal set: (contains all elements under consideration)
Subsets: means every element of is in . denotes a proper subset ( and ).
Set Operations
| Operation | Symbol | Definition |
|---|---|---|
| Union | ||
| Intersection | ||
| Difference | ||
| Complement | or |
Cartesian product:
Power set: is the set of all subsets of . If , then .
Cardinality
The cardinality of a set is the number of elements it contains.
- Finite sets have a natural number as cardinality
- Countably infinite sets can be put in one-to-one correspondence with (e.g. )
- Uncountable sets cannot (e.g. )
Functions and Relations
Relations
A relation from set to set is a subset of . We write or .
Properties of relations on a set :
| Property | Definition |
|---|---|
| Reflexive | |
| Symmetric | |
| Transitive | |
| Antisymmetric |
An equivalence relation is reflexive, symmetric, and transitive. It partitions a set into equivalence classes.
A partial order is reflexive, antisymmetric, and transitive (e.g. on integers, on sets).
Functions
A function assigns exactly one element of to each element of .
Types of functions:
- Injective (one-to-one): implies
- Surjective (onto): every element of is mapped to by some element of
- Bijective: both injective and surjective
Composition:
Inverse: exists if and only if is bijective.
Combinatorics
Counting Principles
Sum rule: If task can be done in ways and task in ways, and they cannot be done simultaneously, then or can be done in ways.
Product rule: If task can be done in ways and task in ways, then followed by can be done in ways.
Inclusion-exclusion principle:
For three sets:
Permutations and Combinations
Permutations (order matters):
- distinct objects ():
- objects from ():
- With repetition ():
Combinations (order doesn’t matter):
- objects from ():
- With repetition ():
Binomial Theorem
The expansion of (for integer ):
Pascal’s triangle displays binomial coefficients, where each entry is the sum of the two entries above it.
Properties of binomial coefficients:
- (for )
- (symmetry, for )
- (Pascal’s identity, for and )
Pigeonhole Principle
Basic form: If objects are placed into boxes (), at least one box contains more than one object.
Generalised form: If objects are placed into boxes (), at least one box contains at least objects.
Applications:
- In any group of people, at least share a birth month
- In a sequence of distinct numbers, there exists an increasing or decreasing subsequence of length (Erdős–Szekeres theorem)
Graph Theory
Basic Definitions
A graph consists of vertices and edges connecting pairs of vertices (unless noted otherwise, graphs below are finite, undirected, and simple—no self-loops or parallel edges).
- Undirected graph: edges have no direction
- Directed graph (digraph): edges have direction
- Weighted graph: edges have associated values
The degree of a vertex in an undirected graph is the number of edges incident to it (in a multigraph with self-loops, each loop contributes to the degree). In directed graphs, we distinguish in-degree and out-degree.
Handshaking lemma (for finite undirected graphs): The sum of all vertex degrees equals twice the number of edges: .
Special Graphs
- Complete graph : every pair of distinct vertices is connected
- Bipartite graph: vertices can be partitioned into two sets with edges only between sets
- Tree: finite connected acyclic graph; a non-empty tree on vertices has exactly edges
- Planar graph: can be drawn in the plane without edge crossings
Euler’s formula for finite connected planar graphs: (where is the number of faces, including the unbounded outer face).
Graph Properties
A walk is a sequence of vertices connected by edges. A path is a walk with no repeated vertices. A cycle (in a simple graph) is a closed walk of length at least whose interior vertices are distinct and whose only repeated vertex is the start/end vertex.
A graph is connected if there is a path between every pair of vertices.
Eulerian path: visits every edge exactly once. In a finite undirected graph, an Eulerian path exists iff all vertices of non-zero degree lie in a single connected component and exactly or vertices have odd degree (an Eulerian circuit exists iff vertices have odd degree).
Hamiltonian path: visits every vertex exactly once (NP-complete to determine).
Graph colouring: assigning colours to vertices such that no adjacent vertices share a colour. The chromatic number is the minimum number of colours needed.
Algorithms
Breadth-first search (BFS): explores all neighbours before moving deeper. Uses a queue.
Depth-first search (DFS): explores as far as possible before backtracking. Uses a stack.
Dijkstra’s algorithm: finds shortest paths from a source vertex in weighted graphs with non-negative weights.
Minimum spanning tree:
- Prim’s algorithm: grows tree by adding cheapest edge from tree to non-tree vertex
- Kruskal’s algorithm: adds cheapest edge that doesn’t create a cycle
Recurrence Relations
Definitions
A recurrence relation defines a sequence in terms of previous terms.
Examples:
- Fibonacci: , with ,
- Factorial: , with
Solving Recurrences
Iteration method: repeatedly substitute until a pattern emerges.
Characteristic equation method for linear recurrences:
For , solve to find the characteristic roots.
Master theorem for divide-and-conquer recurrences of the form with constants , , and asymptotically positive :
- Case 1: If for some constant , then
- Case 2: If , then
- Case 3: If for some constant , and the regularity condition holds for some constant and all sufficiently large , then
Applications in Computer Science
- Algorithm analysis: Big-O notation, complexity classes
- Data structures: trees, graphs, hash tables
- Cryptography: modular arithmetic, prime numbers
- Database theory: relational algebra uses set theory
- Formal languages and automata: finite state machines, regular expressions
Learning Resources
Books
- Discrete Mathematics with Applications by Susanna Epp
- Discrete Mathematics and Its Applications by Kenneth Rosen
- Concrete Mathematics by Graham, Knuth, Patashnik
Courses
Related Topics
- Mathematical Proofs
- Number Theory
- Probability & Statistics
- Linear Algebra — vector spaces and matrix algebra
- Machine Learning — graph algorithms, combinatorics in ML