Guest Lecturer - Yuval Sanders
2 October 2025
In theoretical computer science, we treat computations as procedures for rewriting strings. There are two main types of jobs: solve a function problem or a decision problem.
While both problem types are important, complexity theory focuses primarily on decision problems.
This is not a real restriction: any function problem can be solved by asking polynomially many decision questions. For example, to compute a function \(f\) with output length \(m(n)\), we can ask \(m(n)\) questions of the form “Is the \(i\)-th bit of \(f(x)\) equal to 1?”
Since this overhead is only polynomial, complexity classes defined for decision problems naturally extend to function problems.
We define strings in terms of an alphabet. An alphabet is simply a finite set of symbols. We frequently use the alphabet \(\mathbb{B} = \{0, 1\}\), which we call the binary alphabet.
A string is a sequence of characters from some specified alphabet. A ‘binary’ string (a.k.a. bitstring) is a string over the binary alphabet. The length of a string is the number of symbols in the string. The set of all strings over an alphabet \(\Sigma\) is denoted by \(\Sigma^*\).
A language over an alphabet \(\Sigma\) is a set \(L \subseteq \Sigma^*\). Every decision problem corresponds to a language: the set of strings for which the answer is YES.
For example:
The fundamental computational question becomes: is \(x \in L\)? This is called the membership problem for language \(L\).
To study what can be computed and how efficiently, we need a formal model of computation. The Turing machine, introduced by Alan Turing in 1936, provides this foundation.
A Turing machine is an idealized computing device that:
A Turing machine recognizes a language \(L\) if it accepts exactly the strings in \(L\). It may reject or loop forever on strings not in \(L\).
A Turing machine decides a language \(L\) if it recognizes \(L\) and halts on all inputs. Machines that decide languages are called deciders.
For complexity theory, we focus exclusively on deciders, since we want to measure the time taken to solve problems.
Definition: A Turing machine is a tuple \((Q, \Sigma, \Gamma, \delta, q_0, q_{\text{accept}}, q_{\text{reject}})\), where:
Informally, a Turing machine (TM) operates as follows.
A configuration of a Turing machine is a complete description of its current state: the current state, the tape contents, and the head position.
A computation is a sequence of configurations, where each configuration follows from the previous one by applying the transition function \(\delta\). The machine starts in configuration \((q_0, x, 0)\) where \(x\) is the input string.
The machine accepts input \(x\) if the computation eventually reaches a configuration with state \(q_{\text{accept}}\). It rejects if it reaches state \(q_{\text{reject}}\). It loops if the computation never halts.
The set of strings \(L\) accepted by a Turing machine \(M\) is the language recognized by the Turing machine.
If the Turing machine also rejects all strings not in \(L\), we say the Turing machine decides \(L\).
Notice that a decider is guaranteed to halt on all inputs.
To analyze efficiency, we count the number of steps a Turing machine takes.
Definition: The running time of a Turing machine \(M\) on input \(x\), denoted \(\text{Time}(M, x)\), is the number of transitions \(M\) makes before halting.
The worst-case time complexity of \(M\) is the function \(T_M(n) = \max\{\text{Time}(M, x) : |x| = n\}\).
P = Languages decidable by polynomial-time deterministic TMs
Formally, \(L \in \mathsf{P}\) if there exists a decider \(M\) and polynomial \(p\) such that \[ T_M(n) = O(p(n)). \]
Let \(f,g : \mathbb{N} \to \mathbb{N}\) be functions. We say \(f \in O(g)\) if there exists \(n_0,c \in \mathbb{N}\) such that, for all \(n > n_0\), \(f(n) \leq c \cdot g(n)\).
Two reasons:
Feasibility: polynomials grow moderately, unlike exponentials. Thus polynomial-time algorithms are, generally speaking, usable.
Composition: if \(p, q\) are polynomials, then so is \(p \circ q\). Thus composing two polynomial-time algorithms produces another polynomial-time algorithm.
NP = Languages with polynomial-time verifiable certificates
\(L \in\mathsf{NP}\) if there exists a polynomial-time verifier \(V\) and polynomial \(p\) such that:
\[x \in L \iff \exists w \in \{0,1\}^{p(|x|)} : V(x,w) = 1\]
P vs NP Problem: Does P = NP?
The hardest problems in NP:
A language L is NP-complete if L is in NP and every NP language reduces to L in polynomial time.
Cook-Levin Theorem (1971): The SAT problem – determine if a logical proposition (collection of AND, OR, and NOT) can be satisfied by an assignment of truth values to atomic statements – is NP-complete
Significance:
While Turing machines are our canonical model, the Boolean circuit model offers some compelling advantages.
A Boolean circuit is a directed acyclic graph with three kinds of nodes:
The size of a circuit is the number of gates. The depth is the longest path from input to output.
A single circuit handles inputs of fixed size. For languages, we need a family of circuits.
A circuit family is a sequence \(\{C_n\}_{n \in \mathbb{N}}\) where \(C_n\) is a circuit accepting \(n\)-bit inputs.
A circuit family decides language \(L\) if: \[x \in L \Rightarrow C_{|x|}(x) = 1 \text{ \& } x \notin L \Rightarrow C_{|x|}(x) = 0\]
Without restrictions, circuit families are too powerful—they can decide undecidable languages!
(This is because you can encode lookup tables.)
A circuit family \(\{C_n\}\) is uniform if there exists a polynomial-time TM that, on input \(1^n\), outputs a description of \(C_n\).
Key insight: Uniform circuit families ≈ Turing machines
P/poly = Languages decidable by polynomial-size circuit families
Note: P/poly includes non-uniform families, so P ⊆ P/poly.
Also: ‘uniformity’ has various definitions in the literature, but consistently requires that circuits can be generated by an efficient algorithm.
The disagreements center on what notion of efficiency is appropriate - polynomial time, logarithmic space, or even more restricted classes.
Real algorithms often use randomness effectively. We model this by giving Turing machines access to random bits.
A probabilistic Turing machine (PTM) is a TM with an additional random tape containing uniformly random bits.
For PTM \(M\) and input \(x\):
BPP = Languages decidable by polynomial-time PTMs with bounded error
\(L \in\mathsf{BPP}\) if there exists polynomial-time PTM \(M\) such that:
The constants 2/3 and 1/3 are arbitrary; any constants with a gap work. Choosing 2/3 and 1/3 is just a convention.
The error probability in BPP can be made exponentially small:
If \(L \in\mathsf{BPP}\) , then for any polynomial \(p(n)\), there exists a PTM \(M'\) running in polynomial time such that:
Proof idea: Run the original algorithm multiple times and take majority vote.
PP = Languages decidable by polynomial-time PTMs with unbounded error
\(L \in\mathsf{PP}\) if there exists polynomial-time PTM \(M\) such that:
Note: The gap can be exponentially small!
Known relationships among these classes:
\[\mathsf{P} \subseteq \mathsf{BPP} \subseteq \mathsf{PP} \subseteq \mathsf{PSPACE}\]
\[\mathsf{NP} \subseteq \mathsf{PP}\]
Open Problems:
A language \(L ∈ \mathsf{MA}\) if there exists a polynomial-time PTM \(V\) (the verifier) and polynomials \(p(n)\) and \(q(n)\) such that:
where the probability is over \(V\)’s random bits \(r ∈ {0,1}^q(|x|)\).
It is believed that MA = NP, and it is known that NP ⊆ MA ⊆ PP.
Quantum computers manipulate quantum states using unitary operations.
Key components:
A quantum circuit is a sequence of quantum gates followed by measurement.
A quantum circuit on \(n\) qubits consists of:
Universal gate sets:
BQP = Languages decidable by uniform families of polynomial-size quantum circuits with bounded error
\(L \in \mathsf{BQP}\) if there exists a uniform family of polynomial-size quantum circuits \(\{Q_n\}\) such that:
Key features:
Known relationships: \[\mathsf{BPP} \subseteq \mathsf{BQP} \subseteq \mathsf{PP} \subseteq \mathsf{PSPACE}\]
Main proven quantum advantages:
Note: Hamiltonian simulation is often noted as an advantage, but there is no proof of this. The difficulty is in formulating the computational problem. Too easy and it is in BPP. Too hard and it is not in BQP.
Can a classical verifier check quantum computations?
Challenge: Quantum states cannot be efficiently described classically
Solution: Quantum Merlin-Arthur games—the quantum analogue of MA (=NP?)
QMA = Quantum Merlin-Arthur
\(L \in \mathsf{QMA}\) if there exists polynomial-time quantum verifier \(V\) and polynomial \(p\) such that:
Completeness: \[x \in L \Rightarrow \exists |\psi\rangle \in \mathbb{C}^{2^{p(|x|)}}: \Pr[V(x, |\psi\rangle) = 1] \geq 2/3\]
Soundness: \[x \notin L \Rightarrow \forall |\psi\rangle \in \mathbb{C}^{2^{p(|x|)}}: \Pr[V(x, |\psi\rangle) = 1] \leq 1/3\]
Local Hamiltonian Problem:
This is the quantum analogue of SAT!
Known relationships: \[\mathsf{NP} \subseteq \mathsf{QMA} \subseteq \mathsf{PP}\] \[\mathsf{BQP} \subseteq \mathsf{QMA}\]
Open problems:
An oracle for language \(A\) is a “black box” that instantly answers membership queries.
\(\mathsf{P}^A\) = Languages decidable in polynomial time with oracle access to \(A\)
Similarly define \(\mathsf{NP}^A\), \(\mathsf{BPP}^A\), \(\mathsf{BQP}^A\), etc.
Baker-Gill-Solovay (1975):
Implication: The P vs NP question doesn’t relativize—need non-relativizing techniques!
Simon (1994): There exists oracle \(A\) such that \(\mathsf{BQP}^A \not\subseteq \mathsf{BPP}^A\)
Simon’s Problem:
Classical: Requires \(\Omega(2^{n/2})\) queries
Quantum: Requires \(O(n)\) queries
Oracular Function Inversion Problem:
Classical approach: Try values until finding \(f(x) = 1\)
Quantum approach (Grover):
Result: Quadratic speedup for unstructured search!
The key insight: Grover’s algorithm is a rotation in a 2D subspace
Define two orthogonal states:
For N items with 1 solution:
Any state during Grover’s algorithm stays in \(\operatorname{span}\{|α⟩, |β⟩\}\):
\[|ψ⟩ = \cos(θ)|α⟩ + \sin(θ)|β⟩\]
Initial state: Uniform superposition \[|ψ₀⟩ = (1/√N) \sum_x |x⟩ = \sin(θ₀)|β⟩ + \cos(θ₀)|α⟩\]
Where: \(\sin(θ₀) = 1/\sqrt{N}, \cos(θ₀) = \sqrt{\frac{N-1}{N}}\)
So: \(θ₀ ≈ 1/\sqrt{N}\) (small angle for large \(N\))
Oracle operator: \(O|x⟩ = (-1)^{f(x)}|x⟩\)
Diffusion operator: \(D = 2|ψ₀⟩⟨ψ₀| - I\)
Key geometric fact: Reflecting twice across lines separated by angle φ rotates by 2φ
In Grover:
Result: Each iteration rotates by \(2θ₀\)
After \(k\) iterations: \(θ_k = (2k + 1)θ₀\)
Goal: Rotate to θ ≈ π/2 (pointing at |β⟩)
(2k + 1)θ₀ ≈ π/2
Solving: k ≈ π/(4θ₀) - 1/2
Since θ₀ ≈ 1/√N:
k_optimal ≈ (π/4)√N
Measurement succeeds with high probability when θ ≈ π/2
If you run too many iterations:
Grover’s algorithm is periodic with period ≈ π√N
This is why knowing \(N\) (approximately) matters for the algorithm
The initial angle θ₀ = arcsin(1/√N) is fixed by the problem
Each iteration can only rotate by O(θ₀) - Any unitary that doesn’t know the solution can’t rotate faster
To reach π/2 requires Ω(1/θ₀) = Ω(√N) iterations
This geometric view makes the √N bound obvious
Bennett-Bernstein-Brassard-Vazirani (1997): Any quantum algorithm for unstructured search requires \(\Omega(\sqrt{2^n})\) queries.
Implications:
\[\mathsf{P} \subseteq \mathsf{BPP} \subseteq \mathsf{BQP} \subseteq \mathsf{PP} \subseteq \mathsf{PSPACE}\]
\[\mathsf{P} \subseteq \mathsf{NP} \subseteq \mathsf{QMA} \subseteq \mathsf{PP}\]
Major open questions:
Textbooks: - Nielsen & Chuang: Quantum Computation and Quantum Information - Arora & Barak: Computational Complexity: A Modern Approach - Watrous: The Theory of Quantum Information
Key Papers: - Shor (1997): Polynomial-time algorithms for factoring and discrete logarithms - Grover (1996): A fast quantum mechanical algorithm for database search - Kitaev (1999): Quantum NP and QMA-completeness