PRACTICE →↑ BACK TO TOP

Let's talk

contact@adriamics.com

Discrete Math

GitHub Changelog -

  • 1

Discrete Mathematics

Discrete mathematics studies finite or countable structures such as propositions, sets, integers, graphs, and algorithms. It is the language of proofs and the mathematical foundation of computer science.

Before you begin: Use Logic before this course. Discrete Math introduces the proof techniques used throughout the subject; for a focused, deeper treatment of constructing and presenting proofs, continue to Proof Writing afterward.

Logic and propositions

A proposition is a statement that is either true or false.

Examples:

  • "7 is prime" is a proposition.

  • "" is not a proposition until is specified.

Logical operators

OperatorMeaningSymbol
Negationnot
And and
Or or
Implyif , then
Biconditional iff

The implication is false only when is true and is false.

Common equivalences

These are used constantly in simplification and proof:

Quantifiers

Quantifiers turn predicates into statements.

  • Universal: means "for all , holds"

  • Existential: means "there exists an such that holds"

Negating quantified statements:

Converse, inverse, contrapositive

Given :

  • Converse:

  • Inverse:

  • Contrapositive:

Only the contrapositive is logically equivalent to the original implication.

Example

Statement:

This is true. A clean proof is:

If is even, then for some integer . Then

so is even.


Sets, functions, and relations

Sets

A set is an unordered collection of distinct objects.

Common notation:

Basic operations:

Useful identities:

Power sets

The power set is the set of all subsets of .

If , then:

Cartesian products

The Cartesian product is:

If and , then:

Functions

A function assigns each element of exactly one element of .

Important properties:

  • Injective: different inputs give different outputs

  • Surjective: every element of the codomain is hit

  • Bijective: both injective and surjective

If is bijective, then it has an inverse .

Relations

A relation on a set is a subset of .

Important properties:

  • Reflexive: for all

  • Symmetric: if , then

  • Antisymmetric: if and are both in , then

  • Transitive: if and are in , then is in

Equivalence relations and partitions

An equivalence relation is reflexive, symmetric, and transitive.

It breaks a set into equivalence classes.

Example: congruence modulo

Partial orders

A partial order is reflexive, antisymmetric, and transitive.

Examples:

  • on sets

  • on integers

  • Divisibility on positive integers

Partially ordered sets are often visualized with Hasse diagrams.


Proof techniques

Discrete math is proof-heavy. Knowing the structure of a proof matters as much as knowing the definitions.

This is a first introduction to proof methods in context. After completing Discrete Math, use Proof Writing for dedicated practice with proof structure, strategy, and presentation.

Direct proof

Use definitions and algebraic manipulation to move from assumptions to conclusion.

Typical pattern:

  1. Assume the hypothesis.

  2. Expand the relevant definitions.

  3. Derive the target statement.

Proof by contrapositive

To prove , prove the equivalent statement:

This is often easier when the conclusion is negative or divisibility-based.

Proof by contradiction

Assume the statement is false and derive an impossibility.

Typical pattern:

  1. Assume the claim fails.

  2. Combine that assumption with known facts.

  3. Reach a contradiction such as or "an integer is both even and odd".

Proof by cases

Split the domain into exhaustive cases and prove the claim in each one.

Example: for integers, common cases are even/odd or positive/zero/negative.

Existence and uniqueness

For "there exists a unique such that ":

  1. Prove existence: show some satisfies .

  2. Prove uniqueness: if and both satisfy , then .

Common proof pitfall

Do not verify a general statement with a few examples. Examples can suggest a pattern, but they do not prove it.


Induction and recursion

Mathematical induction

Induction proves statements indexed by the positive integers.

To prove for all :

  1. Base case: prove .

  2. Inductive step: assume is true for an arbitrary .

  3. Use that assumption to prove .

This assumption is the inductive hypothesis.

Example

Prove:

Base case :

Inductive step: assume true for . Then

so it holds for .

Strong induction

In strong induction, assume all earlier cases:

and use them to prove .

This is useful when each case depends on several previous ones.

Recursive definitions

Many discrete objects are defined recursively.

Example: Fibonacci numbers

To work with recursive definitions:

  1. Identify base cases.

  2. Identify the recurrence rule.

  3. Check whether the rule determines each later value uniquely.


Counting and combinatorics

Counting arguments appear everywhere in probability, algorithms, graph theory, and proof.

Sum and product rules

  • Sum rule: if tasks are mutually exclusive and can be done in or ways, total ways =

  • Product rule: if a process has stages with then choices, total ways =

Factorials and permutations

The number of ordered arrangements of objects chosen from is:

Combinations

The number of unordered selections of objects from is:

Useful identity:

Pascal identity:

Binomial theorem

Counting with repetition

If repetition is allowed and there are choices for each of positions, the count is:

The number of multisets of size chosen from types is:

Inclusion-exclusion

For two sets:

For three sets:

Pigeonhole principle

If more than objects are placed into boxes, at least one box contains at least two objects.

General form:

If objects are placed into boxes, some box has at least

objects.


Discrete probability

Probability in discrete math is usually built on counting.

Sample spaces and events

  • Sample space:

  • Event: subset of

If outcomes are equally likely:

Basic rules

If and are disjoint:

Conditional probability

provided .

Independence

Events and are independent if:

Independence is not the same as disjointness.

Expected value

For a discrete random variable :

Linearity of expectation:

This holds whether or not and are independent.

Variance

where .

Equivalent formula:


Number theory and modular arithmetic

Divisibility

For integers and with , we say divides , written

if there exists an integer such that .

Useful facts:

  • If and , then

  • If , then for any integer

Prime numbers

A prime number is an integer greater than with exactly two positive divisors: and itself.

Fundamental theorem of arithmetic:

Every integer can be written uniquely, up to order, as a product of primes.

Greatest common divisor

The greatest common divisor of and is written:

Euclidean algorithm:

repeated until the remainder is .

Modular arithmetic

Congruence modulo means:

You can add, subtract, and multiply congruences:

Division is not automatically valid modulo .

Modular inverses

An integer has a multiplicative inverse modulo iff:

Then there exists such that:

Example

To solve

note that because . Therefore


Graphs and trees

A graph consists of vertices and edges.

Notation:

Basic terminology

  • Degree of a vertex: number of incident edges

  • Path: sequence of adjacent vertices

  • Cycle: closed path with no repeated edges

  • Connected graph: every pair of vertices is joined by a path

Handshaking lemma

For any finite undirected graph:

This implies the number of odd-degree vertices is even.

Special graph classes

  • Complete graph:

  • Bipartite graph: vertices split into two parts and edges go only across

  • Complete bipartite graph:

For an undirected graph, the graph is bipartite if and only if it has no odd cycle. (The qualification matters: this statement is not the definition for directed graphs.)

Trees

A tree is a connected graph with no cycles.

Equivalent characterizations of a tree with vertices:

  • It is connected and has edges

  • It is acyclic and has edges

  • There is a unique simple path between any two vertices

Rooted trees

In a rooted tree:

  • One vertex is the root

  • Parent/child relations are defined

  • Depth measures distance from the root

Rooted trees are used heavily in recursion, parsing, and search algorithms.

Traversals

Common traversal orders:

  • Preorder

  • Inorder

  • Postorder

  • Breadth-first search


Algorithms, growth, and recurrences

Discrete math often studies whether a procedure is correct and how quickly it grows.

Asymptotic notation

For functions and :

means grows no faster than a constant multiple of for sufficiently large .

means grows at least as fast as a constant multiple of .

means both are true.

Growth hierarchy

From slower to faster, a common order is:

Recurrence relations

A recurrence defines a sequence from earlier terms.

Examples:

Solving simple recurrences

Arithmetic-type recurrence:

has solution:

Geometric-type recurrence:

has solution:

Algorithm correctness

To show an algorithm is correct, prove:

  1. It terminates.

  2. If it terminates, the output satisfies the specification.

Loop invariants are a standard proof tool:

  • State a property true before the loop starts.

  • Show one iteration preserves it.

  • Use it at termination to prove correctness.


Problem-solving workflow

Use this checklist for most discrete mathematics problems.

Step 1: Identify the object type

Ask what kind of structure you are working with:

  • Proposition

  • Set

  • Function

  • Relation

  • Integer

  • Graph

  • Sequence

  • Counting problem

The definitions depend on the object type.

Step 2: Translate the statement into formal language

Rewrite informal language using symbols when possible:

  • Quantifiers

  • Set notation

  • Divisibility notation

  • Graph terminology

This usually exposes the proof strategy.

Step 3: Choose the right tool

Typical matches:

  • Implication: direct proof or contrapositive

  • Nonexistence: contradiction

  • Integer-indexed claim: induction

  • Finite arrangements: sum/product rule, permutations, combinations

  • Congruence problem: modular arithmetic

  • Structure with vertices and edges: graph methods

Step 4: Write from definitions

Most proofs become manageable once the key definition is expanded.

Examples:

  • Even means

  • Divisible means

  • Injective means

  • Tree means connected and acyclic

Step 5: Check edge cases

Small values, empty sets, parity changes, and boundary cases often break careless arguments.

Step 6: Validate the conclusion type

Make sure the proof ends with the right type of claim:

  • Equality proved algebraically

  • Existence proved by construction

  • Uniqueness proved by comparison

  • Counting answer justified by combinatorial model


Formula sheet

Logic

Sets

Counting

Probability

Number theory

Graphs

For a tree with vertices:

Growth


Common mistakes to avoid

  • Confusing the converse of a statement with its contrapositive.

  • Negating quantified statements incorrectly.

  • Treating examples as proof.

  • Using permutations when order does not matter.

  • Using combinations when order does matter.

  • Cancelling terms in modular arithmetic without checking inverses exist.

  • Assuming disjoint events are independent.

  • Forgetting that a relation and a function are different objects.

  • Claiming a graph is a tree without checking both connectedness and acyclicity.

  • Using asymptotic notation as if it were an exact equality.

Sources