Mathematical and Algorithmic Prerequisites
The proof, asymptotic, graph, probability, and machine-model tools used throughout complexity theory.
Goals
- Read asymptotic claims with their quantifiers and hidden constants exposed.
- Measure an instance by the length of its encoding, not by the value it represents.
- select and write direct, inductive, contradictory, diagonal, and counting proofs.
- Use finite probability spaces, conditional probability, expectation, and union bounds safely.
1. What complexity measures
Complexity theory asks how many resources are sufficient or necessary as the input grows. The variable is normally the encoding length . If the mathematical input is the integer , its binary representation has length , whereas its unary representation has length . Thus an algorithm taking steps is exponential in the binary input length but linear in the unary length. Encoding is not clerical detail: it determines the question.
A decision problem is represented by a language . A decider must halt on every input and satisfy
An algorithm is the abstract method; a machine model specifies which operations count as one step. Later lessons use Turing machines so that “time” and “space” have precise meanings. Robust complexity classes tolerate reasonable simulation overhead, but an analysis must still name its model and encoding.
2. Sets, strings, functions, and graphs
For an alphabet , contains all finite strings, including the empty string . Concatenation is written , and is length. A tuple needs a uniquely decodable encoding such as ; merely writing can be ambiguous. A function is increasing if implies , and it is unbounded if every constant is eventually exceeded.
A graph may be encoded by an adjacency matrix using bits or by an edge list using bits under a standard vertex-numbering convention. A polynomial-time claim under one reasonable graph encoding usually transfers to another only after proving a polynomial relation between encoding lengths.
Worked encoding example. Suppose an algorithm enumerates all integers from through . It takes iterations. On input this is linear. On the binary encoding of , whose length is , it takes iterations. The code did not change; the complexity statement did.
3. Asymptotic notation with quantifiers
For eventually nonnegative functions,
Big- is an eventual upper bound, not equality. Small- is strict asymptotic domination. For example, , but .
Claim. .
Upper bound. For , and , so . Choose .
Lower bound. For every , . Choose . Both quantified witnesses are required.
Useful growth facts include
Changing a logarithm's constant base changes it by a constant factor. Moving a constant into an exponent is different: and are generally not within a constant multiplicative factor.
Growth-rate map
Use the visualization by choosing an input size and comparing the same functions on linear and logarithmic vertical scales. The order is asymptotic; crossings at small do not invalidate it.
4. Proof methods
Direct proof and construction
To prove , begin with an arbitrary and derive . To prove membership in a complexity class, construct one machine meeting both correctness and resource bounds. A slow alternative algorithm does not disprove membership because class membership is existential.
Contrapositive and contradiction
The contrapositive of is and is logically equivalent. A contradiction proof assumes the negation of the desired statement and derives an impossibility. Always state what was negated: negating yields .
Induction
For a statement , prove a base case and then . Strong induction may assume all earlier cases. In machine simulations, the invariant often says: “after simulated steps, the encoding represents exactly the simulated machine's configuration after steps.” The base case verifies the initial encoding; the step verifies one transition.
Counting and pigeonhole
If objects are placed in fewer than boxes, one box gets at least two objects. Complexity proofs count strings, machines, circuits, or configurations. For example, there are binary strings of length but Boolean functions on bits. This enormous gap underlies many existence arguments, though counting alone may not identify an explicit hard function.
Diagonalization
Given an enumeration , define an object that differs from on the th designated input. The hard part is not the slogan “do the opposite”; it is ensuring that the diagonal simulator fits its resource budget and halts. Hierarchy theorems therefore require constructibility and a sufficient asymptotic gap.
5. Probability toolkit
A finite probability space consists of outcomes and a distribution with total mass . An event is a subset of . Conditional probability is
Events are independent when . Pairwise independence does not imply mutual independence.
The union bound requires no independence:
If independent trials each fail with probability , the probability all fail is . Independence is essential for multiplication.
For a random variable , linearity of expectation says
even when the are dependent. With indicator for event , . Thus if counts successful trials, its expectation is the sum of their success probabilities.
Example: amplification. Suppose an independent run succeeds with probability at least . Run it times and accept if any run succeeds when false acceptance is impossible. Failure requires every run to fail, so it is at most . For two-sided error with majority vote, a concentration bound is needed; simply writing would be wrong.
“With high probability” normally means probability at least for some fixed , or another explicitly stated bound approaching . It does not merely mean probability greater than .
6. Reading and writing formal claims
Quantifier order records dependence. In
the constant may depend on but not on . Replacing it by asserts one universal constant and is much stronger. Before manipulating a proof, annotate every constant with what it may depend on.
For a language-class claim, separate three obligations:
- Semantics: the machine accepts exactly the intended strings.
- Termination: every required computation halts.
- Resources: the bound holds for every input of the given length, including no-instances.
Worst-case time is a maximum over inputs of length , not an average and not the time on a convenient example.
Common mistakes
- Hiding a constant that actually depends on the input.
- Measuring a number by its value instead of its bit length.
- Reversing an implication when only its contrapositive is valid.
- Multiplying probabilities without independence.
- Proving correctness only for yes-instances or resource use only on accepting runs.
- Treating as a function rather than a set of eventual bounds.
- Assuming “polynomial” means practical for every exponent and constant.
Exercises
Exercise 1 — Prove
Prove from the definition that . Exhibit explicit constants and in each direction.
Solution
Claim. .
Upper bound (). For , , hence
Take and .
Lower bound (). For every , . Take and .
Thus and , so . Constants need not be optimal; they must be positive and uniform for all sufficiently large .
Exercise 2 — Refute
Prove that the claim is false. Write the negation of the definition and complete it.
Solution
Negation of . The claim means
Its negation is
Proof. Since , for every there exists with .
What this is not. Checking a few small values is not a proof: the definition concerns eventual behavior.
Exercise 3 — Unary versus binary encoding
Let be the language of unary inputs , and let be the language of binary encodings of the same integers. An algorithm counts from to in steps. Prove that it runs in linear time in the input length on inputs from , but exponential time in the input length on inputs from . Explain why there is no contradiction.
Solution
On we have and steps — linear time.
On a binary encoding of of length , the step count is — exponential in the input length.
There is no contradiction: the same program is measured against different input lengths. Encoding is part of the problem, so the complexity classification depends on it.
Exercise 4 — Union bound without independence
We sample values; for each , the probability that value is bad is at most . Prove that the probability that at least one value is bad is at most , without assuming independence. Deduce the case . Explain why one may not multiply success probabilities without an extra hypothesis.
Solution
Let be the event that value is bad. By the union bound,
The union bound requires no independence. For the bound is at most .
Writing requires independence. Without it, the product is unjustified.
Exercise 5 — Expectation with dependence
Let be a graph. For each vertex let indicate that is selected, and assume for every . Let . Prove that even if the selection mechanism introduces dependence among vertices.
Solution
By linearity of expectation,
Linearity does not require independence. Dependence affects variance and tail bounds, not the expectation itself.
Summary
Complexity arguments stand on four habits: measure encoding length, expose quantifiers, match the proof method to the claim, and define the probability experiment. These habits will reappear in simulations, hierarchy arguments, nondeterministic computation, and padding.
Guided practice
Task 1 — Quantifiers and constant dependence
State precisely and compare the strength of:
- For every machine there is a constant such that for every input , .
- There is a single constant such that for every machine and every input , .
In which statement may the constant depend on ? May one choose the constant after seeing ?
Solution
The first statement is
The constant may depend on but not on : one may not choose after seeing .
The second is
and is much stronger. Writing the dependence in a subscript ( versus ) prevents exam confusion.
Task 2 — Three parts of a membership proof
Let be a language. State exactly what must be proved to claim when is defined via machines with a given resource bound. Explain why a single example input is insufficient, and why an additional slow algorithm does not disprove membership.
Solution
Separate three obligations:
- Semantics: the machine accepts exactly the strings of and rejects the complement.
- Halting: every required computation halts (accept and reject).
- Resources: the bound holds for every input of length , including no-instances.
Examples do not discharge . Class membership is existential in the algorithm: one correct machine suffices; another slow machine does not disprove membership.
Task 3 — Capstone: time, encoding, and probability
An algorithm receives a binary integer , launches trials, and each trial has a bad event with probability at most (no independence among trials).
- Prove the algorithm is not polynomial in the input length .
- Bound the probability of any bad event.
- Explain when failure probability proves existence of a good choice, and when that is not enough for an efficient algorithm.
- Distinguish expected time from worst-case time.
Solution
-
The input length is . Launching trials takes at least steps, so the time is not polynomial in .
-
By the union bound, without independence:
-
If then , so a good randomness choice exists (the probabilistic method). Existence does not yield an efficient algorithm for finding the choice; that needs sampling, repetition, derandomization, or search.
-
Small expected time does not imply a polynomial bound on every run. A rare huge runtime can keep expectation small while destroying worst-case polynomiality.
In every probabilistic argument, state the distribution, the random variable, whether the bound is expectation or a tail, and what is required for every input.
Sources
- Student-summary evidence: merged course summary, pp. 1, 98, and 141. It is an image-based student summary and is used only to align emphasis and terminology, not as final authority.
- Course evidence: Semester A 2026 transcripts 1-2 for foundational course framing; no exact line locator is asserted here.
- Verification: Michael Sipser, Introduction to the Theory of Computation, 3e, pp. 3-24.
- Verification: Sanjeev Arora and Boaz Barak, Computational Complexity: A Modern Approach draft, pp. 9-14 and Appendix A.
- Verification: Christos Papadimitriou, Computational Complexity, pp. 1-18 and elementary probability material in Chapter 11.