Complexity Theory Module

Complexity Classes: P vs NP

Formal definition of deterministic and nondeterministic Turing machines, polynomial verification, decision problems, and the P vs NP problem.

1. Decision Problems and Formal Languages

In theoretical computer science, computational problems are formalized as Decision Problems—questions with a binary output (YES or NO).
A decision problem corresponds to a formal Language $L \subseteq \Sigma^*$ over a finite alphabet $\Sigma$ (typically binary $\Sigma = {0, 1}$):
$$L = { x \in \Sigma^* \mid \text{the answer to instance } x \text{ is YES} }$$
Example: The PRIMES language is the set of all binary encodings of prime numbers: PRIMES $= {10, 11, 101, 111, 1011, \dots}$.

2. The Class P (Polynomial Time Solvable)

A language $L$ is in the complexity class P if there exists a Deterministic Turing Machine (DTM) $M$ and a constant $k \ge 1$ such that for any input string $x \in \Sigma^*$:
  1. $M$ halts in at most $O(|x|^k)$ steps.
  2. $M$ accepts $x$ if and only if $x \in L$.
$$\mathbf{P} = \bigcup_{k \ge 1} \text{DTIME}(n^k)$$
P represents the mathematical formalization of efficiently solvable problems (e.g. Shortest Path with Dijkstra, Minimum Spanning Tree with Kruskal, 2-SAT, Matrix Multiplication, Primality Testing with AKS).

3. The Class NP (Nondeterministic Polynomial Time)

There are two mathematically equivalent definitions of NP:

Definition A: Verifier Definition (The Certificate View)

A language $L$ is in NP if there exists a deterministic polynomial-time Verifier algorithm $V(x, c)$ and a polynomial $p(n)$ such that:
$$x \in L \iff \exists c \in \Sigma^* \text{ with } |c| \le p(|x|) \text{ such that } V(x, c) = \text{ACCEPT}$$
The string $c$ is called the Certificate (or proof/witness).
  • Intuition: Solving the puzzle from scratch may be hard, but verifying a proposed solution is easy. For instance, finding a Hamiltonian Cycle in a 1,000-node graph is hard, but verifying that a given sequence of 1,000 vertices visits every node once without repeating takes trivial $O(V)$ time.

Definition B: Nondeterministic Machine Definition

$$\mathbf{NP} = \bigcup_{k \ge 1} \text{NTIME}(n^k)$$
A language $L \in \mathbf{NP}$ if there exists a Nondeterministic Turing Machine (NTM) that halts and accepts in polynomial time $O(n^k)$. At each step, an NTM can branch into multiple states simultaneously, accepting if at least one branch accepts.

4. The $P \stackrel{?}{=} NP$ Question

Since any deterministic Turing machine is trivially a nondeterministic Turing machine that never branches:
$$\mathbf{P} \subseteq \mathbf{NP}$$
The million-dollar Clay Millennium Prize question asks whether the reverse inclusion holds:
$$\mathbf{P} \stackrel{?}{=} \mathbf{NP}$$
text
If P = NP                               If P ≠ NP (Consensus Belief)
┌─────────────────────────────────┐     ┌─────────────────────────────────┐
│              NP                 │     │               NP                │
│   ┌─────────────────────────┐   │     │   ┌───────────────┐             │
│   │                         │   │     │   │  NP-Complete  │ (Hardest)   │
│   │           P             │   │     │   └───────────────┘             │
│   │                         │   │     │   ┌───────────────┐             │
│   └─────────────────────────┘   │     │   │       P       │ (Tractable) │
│                                 │     │   └───────────────┘             │
└─────────────────────────────────┘     └─────────────────────────────────┘

Why Most Computer Scientists Believe $P \neq NP$

If $P = NP$, then every task where creativity is needed to find an answer (writing software, discovering mathematical proofs, composing symphonies, breaking modern cryptography) could be automated as quickly as checking the answer. As Donald Knuth noted: "It would be profoundly surprising if discovering a mathematical proof were no harder than reading one."